Add .bin/install.js Updated README.md

This commit is contained in:
Lorenzo Iovino 2024-01-20 10:12:26 +01:00
parent ae301e44f4
commit 0ddea7c1c6
5 changed files with 77 additions and 23 deletions

36
.bin/install.js Normal file
View file

@ -0,0 +1,36 @@
#!/usr/bin/env node
import { execSync } from '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/thisloke/node-base ${repoName}`;
const installDepsCommand = `cd ${repoName} && npm install`;
console.log(`Cloning the repository ${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("Ready to start!");