Created
June 21, 2019 10:46
-
-
Save BretCameron/24f0079bd2c546e704914b86f1b1627a to your computer and use it in GitHub Desktop.
A custom npm init script, which incorporates an initial GitHub commit. The file should be in your home directory.
This file contains hidden or 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
const { execSync } = require('child_process'); | |
function run(func) { | |
console.log(execSync(func).toString()) | |
} | |
module.exports = { | |
name: prompt('package name', basename || package.name), | |
version: prompt('version', '0.0.0'), | |
decription: prompt('description', ''), | |
main: prompt('entry point', 'index.js'), | |
keywords: prompt(function (s) { return s.split(/\s+/) }), | |
author: prompt('author', 'Joe Bloggs <[email protected]> (joebloggs.com)'), | |
license: prompt('license', 'ISC'), | |
repository: prompt('github repository url', '', function (url) { | |
if (url) { | |
run('touch README.md'); | |
run('git init'); | |
run('git add README.md'); | |
run('git commit -m "first commit"'); | |
run(`git remote add origin ${url}`); | |
run('git push -u origin master'); | |
} | |
return url; | |
}), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment