Created
October 17, 2019 08:49
-
-
Save jacobbubu/35c4235d04afcc5052e01d3bc8165cdf to your computer and use it in GitHub Desktop.
Create a github repo. using the name from package.json and then put the repo's url back to `package.repository`
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
name=`node -e "process.stdout.write((require('./package.json').name.replace(/^@[\w\d\-\_]+\//, '')))"` | |
if [ -z ${name+x} ]; then | |
echo 'No "name" field found in package.json' | |
else | |
output=`gh re --browser false --new $name` | |
repo=`echo $output | grep -Eo '(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'` | |
repo+=".git" | |
echo $repo | `node -e "process.stdin.resume();process.stdin.setEncoding('utf8');var gitUrl = '';process.stdin.on('data', function(chunk) { gitUrl = chunk.split('\n')[0]; });process.stdin.on('end', function() {var fs=require('fs');var pkg=require('./package.json');pkg.repository = { type: 'git', url: gitUrl };fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2), 'utf8');})"` | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please install
gh
first,npm i gh -g