Skip to content

Commit

Permalink
fix(cli): remove return promise
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyi7099 committed Jul 30, 2019
1 parent 12377e4 commit fdae6aa
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/cli/create-antd-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const program = new commander.Command(packageJson.name)
.version(packageJson.version)
.arguments('[project-directory]')
.usage(`${chalk.green('[project-directory]')}`)
.action(name => {
.action((name) => {
projectName = name;
})
.option('--use-npm')
Expand All @@ -39,7 +39,7 @@ createApp(projectName, program.useNpm);

function printValidationResults(results) {
if (typeof results !== 'undefined') {
results.forEach(error => {
results.forEach((error) => {
console.error(chalk.red(` * ${error}`));
});
}
Expand Down Expand Up @@ -69,7 +69,7 @@ function checkAppName(appName) {
`Due to the way npm works, the following names are not allowed:\n\n`
) +
chalk.hex('#29CDFF')(
dependencies.map(depName => ` ${depName}`).join('\n')
dependencies.map((depName) => ` ${depName}`).join('\n')
) +
chalk.red('\n\nPlease choose a different project name.')
);
Expand All @@ -87,14 +87,14 @@ function shouldUseYarn() {
}

function executeNodeScript({ cwd, initScriptPath }, data, source) {
return new Promise(resolve => {
return new Promise((resolve) => {
const child = spawn(
process.execPath,
['-e', source, '--', JSON.stringify(data), initScriptPath],
{ cwd, stdio: 'inherit' }
);

child.on('close', code => {
child.on('close', (code) => {
if (code !== 0) {
return;
}
Expand All @@ -121,12 +121,13 @@ function isSafeToCreateProjectIn(root, name) {

const conflicts = fs
.readdirSync(root)
.filter(file => !validFiles.includes(file))
.filter((file) => !validFiles.includes(file))
// IntelliJ IDEA creates module files before CRA is launched
.filter(file => !/\.iml$/.test(file))
.filter((file) => !/\.iml$/.test(file))
// Don't treat log files from previous installation as conflicts
.filter(
file => !errorLogFilePatterns.some(pattern => file.indexOf(pattern) === 0)
(file) =>
!errorLogFilePatterns.some((pattern) => file.indexOf(pattern) === 0)
);

if (conflicts.length > 0) {
Expand All @@ -147,8 +148,8 @@ function isSafeToCreateProjectIn(root, name) {

// Remove any remnant files from a previous installation
const currentFiles = fs.readdirSync(path.join(root));
currentFiles.forEach(file => {
errorLogFilePatterns.forEach(errorLogFilePattern => {
currentFiles.forEach((file) => {
errorLogFilePatterns.forEach((errorLogFilePattern) => {
// This will catch `(npm-debug|yarn-error|yarn-debug).log*` files
if (file.indexOf(errorLogFilePattern) === 0) {
fs.removeSync(path.join(root, file));
Expand Down Expand Up @@ -253,7 +254,6 @@ function run(root, dependencies, useYarn, appName, originalDirectory) {

function install(root, useYarn, dependencies) {
return new Promise((resolve, reject) => {
return resolve();
let command;
let args;
if (useYarn) {
Expand Down Expand Up @@ -281,7 +281,7 @@ function install(root, useYarn, dependencies) {
}

const child = spawn(command, args, { stdio: 'inherit' });
child.on('close', code => {
child.on('close', (code) => {
if (code !== 0) {
reject({
command: `${command} ${args.join(' ')}`
Expand Down

0 comments on commit fdae6aa

Please sign in to comment.