mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 19:32:35 +02:00
fix(create): load entry file after node version checking (#6860)
* refactor(create): add exception handling if external command is fails
refers #4870
85e87b560e
* fix(create): load entry file after node version checking
This commit is contained in:
parent
5e2168ea22
commit
a6e72192fa
1 changed files with 13 additions and 14 deletions
|
@ -13,7 +13,6 @@ import semver from 'semver';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {program} from 'commander';
|
import {program} from 'commander';
|
||||||
import {createRequire} from 'module';
|
import {createRequire} from 'module';
|
||||||
import init from '../lib/index.js';
|
|
||||||
|
|
||||||
const packageJson = createRequire(import.meta.url)('../package.json');
|
const packageJson = createRequire(import.meta.url)('../package.json');
|
||||||
const requiredVersion = packageJson.engines.node;
|
const requiredVersion = packageJson.engines.node;
|
||||||
|
@ -24,14 +23,6 @@ if (!semver.satisfies(process.version, requiredVersion)) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapCommand(fn) {
|
|
||||||
return (...args) =>
|
|
||||||
fn(...args).catch((err) => {
|
|
||||||
logger.error(err.stack);
|
|
||||||
process.exitCode = 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
program.version(packageJson.version);
|
program.version(packageJson.version);
|
||||||
|
|
||||||
program
|
program
|
||||||
|
@ -61,11 +52,14 @@ program
|
||||||
rootDir = '.',
|
rootDir = '.',
|
||||||
{packageManager, skipInstall, typescript, gitStrategy} = {},
|
{packageManager, skipInstall, typescript, gitStrategy} = {},
|
||||||
) => {
|
) => {
|
||||||
wrapCommand(init)(path.resolve(rootDir), siteName, template, {
|
// See https://github.com/facebook/docusaurus/pull/6860
|
||||||
packageManager,
|
import('../lib/index.js').then(({default: init}) => {
|
||||||
skipInstall,
|
init(path.resolve(rootDir), siteName, template, {
|
||||||
typescript,
|
packageManager,
|
||||||
gitStrategy,
|
skipInstall,
|
||||||
|
typescript,
|
||||||
|
gitStrategy,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -75,3 +69,8 @@ program.parse(process.argv);
|
||||||
if (!process.argv.slice(1).length) {
|
if (!process.argv.slice(1).length) {
|
||||||
program.outputHelp();
|
program.outputHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.on('unhandledRejection', (err) => {
|
||||||
|
logger.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue