Created
June 3, 2018 13:15
-
-
Save nerdic-coder/f6d8f6dad501b8b3e1ccebaea47505d0 to your computer and use it in GitHub Desktop.
stencil.cli start-component.js
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
// Command for starting a new stencil component project, example 'stencil start-component my-component' | |
if (process.argv[2] === 'start-component') { | |
if (!shell.which('git')) { | |
shell.echo('Sorry, this script requires git'); | |
shell.exit(1); | |
} | |
var projectName = process.argv[3]; | |
if (!projectName) { | |
shell.echo('Please state the project name after the "start-component" command.'); | |
shell.exit(1); | |
} | |
shell.exec('git clone https://github.com/ionic-team/stencil-component-starter ' + projectName); | |
shell.cd(projectName); | |
shell.echo('Running: git remote rm origin'); | |
shell.exec('git remote rm origin'); | |
shell.echo('Updating npm package names to ' + projectName + '.'); | |
shell.ls('package*.json').forEach(function (file) { | |
shell.sed('-i', 'my-component', projectName, file); | |
}); | |
shell.echo('Updating namespace in stencil.config.js to ' + projectName + '.'); | |
shell.ls('stencil.config.js').forEach(function (file) { | |
shell.sed('-i', 'mycomponent', projectName, file); | |
}); | |
shell.echo('Updating script tag in index.html to ' + projectName + '.'); | |
shell.ls('src/index.html').forEach(function (file) { | |
shell.sed('-i', 'mycomponent', projectName, file); | |
}); | |
shell.echo('Running: npm install'); | |
shell.exec('npm install'); | |
shell.exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment