-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.js
32 lines (22 loc) · 926 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node
const {execSync} = require('child_process');
const runCommand = command => {
try {
execSync(`${command}`, {stdio: 'inherit'});
} catch (e) {
console.error(`Failed to execute ${command}`, e);
return false;
}
return true;
}
const repoName = process.argv[2];
const gitCheckoutCommand = `git clone --depth 1 https://github.com/diva-e/nuxt-project-with-bloomreach.git ${repoName}`;
const installDepsCommand = `cd ${repoName} && npm install`;
console.log(`Cloning the repository with 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("Congratulations! You are ready. Follow the following command to start");
console.log(`cd ${repoName} && npm start`);