create-express-ts-boilerplate
Version:
Express TypeScript Template
30 lines (22 loc) • 879 B
JavaScript
const { execSync } = require('child_process');
const runCommand = (command) => {
try {
execSync(`${command}`, { stdio: 'inherit' });
} catch (err) {
console.error(`Failed to execute ${command}`, err);
return false;
}
return true;
};
const repoName = process.argv[2];
const gitCheckoutCommand = `git clone --depth 1 https://github.com/duterte/create-express-typescript ${repoName}`;
const installDepsCommand = `cd ${repoName} && npm install`;
console.log(`Cloning the repository with the name ${repoName}`);
const checkedOut = runCommand(gitCheckoutCommand);
if (!checkedOut) process.exit(-1);
console.log(`Installing dependencies for ${repoName}`);
const installedDeps = runCommand(installDepsCommand);
if (!installedDeps) process.exit(-1);
console.log(`You are ready!`);
console.log(`cd ${repoName}`);