Skip to content

Commit

Permalink
feat: 🎸 update onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
xsahxl committed Feb 28, 2022
1 parent f940fc3 commit 0fe0938
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/** @format */

import program from '@serverless-devs/commander';
import { registerCommandChecker, logger } from './utils';
import { join } from 'lodash';
Expand Down Expand Up @@ -28,9 +26,8 @@ const pkg = require('../package.json');
.command('clean', `${emoji('💥')} Clean up the environment.`)
.command('component', `${emoji('🔌')} Installed component information.`)
.version(getVersion(), '-v, --version', 'Output the version number.')
.addHelpCommand(false);

await help(system_command);
.addHelpCommand(false)
.parse(process.argv);

// 将参数argv存储到env
process.env['serverless_devs_temp_argv'] = JSON.stringify(process.argv.slice(2));
Expand All @@ -42,6 +39,10 @@ const pkg = require('../package.json');

new UpdateNotifier().init().notify();

if (process.argv.length === 2) {
return await onboarding();
}
await help(system_command);
await new SpecialCommad(system_command).init();

system_command.exitOverride(async error => {
Expand All @@ -52,10 +53,6 @@ const pkg = require('../package.json');
process.exit(0);
}
});
if (process.argv.length > 2) {
return system_command.parse(process.argv);
}
await onboarding();
})().catch(async error => {
await HandleError(error);
});
Expand Down
5 changes: 4 additions & 1 deletion src/onboarding/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import core from '../utils/core';
const { colors, inquirer, fse: fs, getTemplatePath } = core;

async function onboarding() {
const templateFile = await getTemplatePath();
let templateFile: string;
try {
templateFile = await getTemplatePath();
} catch (error) {}
if (fs.existsSync(templateFile)) {
return await projectWithDevs();
}
Expand Down

0 comments on commit 0fe0938

Please sign in to comment.