UNPKG

create-react-app-ts-webpack

Version:

It automatically builds a react, typescript and webpack working environment

58 lines (47 loc) 1.6 kB
#! /usr/bin/env node const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); if (process.argv.length < 3) { console.log('You have to provide a name to your app.'); console.log('For example :'); console.log(' npx create-react-app-ts-webpack my-app'); process.exit(1); } const projectName = process.argv[2]; const currentPath = process.cwd(); const projectPath = path.join(currentPath, projectName); const GIT_REPO = 'https://github.com/vvs-kim/create-react-app-ts-webpack'; if (projectName !== '.') { try { fs.mkdirSync(projectPath); } catch (error) { if (error.code === 'EEXIST') { console.log(projectName); console.log( `The file ${projectName} already exist in the current directory, please give it another name.` ); } else { console.log(error); } process.exit(1); } } async function main() { try { console.log('🚀 Downloading files...'); execSync(`git clone --depth 1 ${GIT_REPO} ${projectPath}`); if (projectName !== '.') { process.chdir(projectPath); } console.log('🗑 Removing useless files'); execSync('npx rimraf ./bin'); execSync('npx rimraf ./.git'); console.log('💾 Yarn install...'); execSync('yarn'); console.log('The installation is done, this is ready to use !'); } catch (error) { console.log(error); } } main();