Skip to content

Commit

Permalink
feat(remove package): remove template package and update v0.2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed May 9, 2020
1 parent 1d8a896 commit 35ffe7a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "installation",
"version": "0.2.17",
"version": "0.2.18",
"description": "An installation template tool",
"keywords": [
"project generator"
Expand Down
26 changes: 26 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ export async function run(
JSON.stringify(appPackage, null, 2) + os.EOL
);

removeTemplatePackage(templatePackageName, useYarn);

if (templateJson.devDependencies) {
const dependencies = Object.entries(
templateJson.devDependencies
Expand Down Expand Up @@ -295,6 +297,30 @@ export async function run(
}
}

export function removeTemplatePackage(templateName: string, useYarn: boolean) {
let command;
let remove;

if (useYarn) {
command = 'yarn';
remove = 'remove';
} else {
command = 'npm';
remove = 'uninstall';
}

console.log(`Removing ${templateName} package...`);
console.log();

const childProcess = spawn.sync(command, [remove, templateName], {
stdio: 'inherit',
});
if (childProcess.status !== 0) {
console.error(`${command} failed`);
process.exit(1);
}
}

export function checkNodeVersion(useTypeScript: boolean) {
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=8.10.0');
if (unsupportedNodeVersion && useTypeScript) {
Expand Down

0 comments on commit 35ffe7a

Please sign in to comment.