Skip to content

Commit

Permalink
feat(yalc): Add publish_yalc_package script for travis scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Dec 27, 2017
1 parent 8b05e84 commit 349cc57
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"release": "./release.js",
"show_changelog": "./show_changelog.js",
"test_downstream_projects": "./test_downstream_projects.js",
"publish_yalc_package": "./publish_yalc_package.js",
"util": "./util.js"
},
"dependencies": {
Expand Down
31 changes: 31 additions & 0 deletions publish_yalc_package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env node
const fs = require('fs');
const util = require('./util');

const ORIG_DIR = process.cwd();

function publishYalcPackage(installDir, githubUrl) {
if (!installDir || !githubUrl) {
throw new Error('Usage: publish_yalc_package [INSTALL_DIR] [GITHUB_URL]');
}

if (!fs.existsSync(installDir)) {
util._exec('git clone '+ githubUrl + ' ' + installDir);
}

process.chdir(installDir);
util._exec('git fetch origin');
util._exec('git reset --hard origin/master');
util._exec('git clean --force -d');
util._exec('yarn --check-files');
util._exec('npm run build');
util._exec('yalc publish');

process.chdir(ORIG_DIR);
}

if (require.main === module) {
publishYalcPackage(process.argv[2], process.argv[3])
}

module.exports = publishYalcPackage;

0 comments on commit 349cc57

Please sign in to comment.