Created
June 30, 2021 22:54
-
-
Save hhimanshu/f33b8d6eb8799b4924bb179a32300dc1 to your computer and use it in GitHub Desktop.
Create NPX based React Starter App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/hhimanshu/react-ts-starter ${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 commands to start"); | |
console.log(`cd ${repoName} && npm start`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment