Skip to content

Commit 349cc57

Browse files
feat(yalc): Add publish_yalc_package script for travis scripts
1 parent 8b05e84 commit 349cc57

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"release": "./release.js",
2424
"show_changelog": "./show_changelog.js",
2525
"test_downstream_projects": "./test_downstream_projects.js",
26+
"publish_yalc_package": "./publish_yalc_package.js",
2627
"util": "./util.js"
2728
},
2829
"dependencies": {

publish_yalc_package.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env node
2+
const fs = require('fs');
3+
const util = require('./util');
4+
5+
const ORIG_DIR = process.cwd();
6+
7+
function publishYalcPackage(installDir, githubUrl) {
8+
if (!installDir || !githubUrl) {
9+
throw new Error('Usage: publish_yalc_package [INSTALL_DIR] [GITHUB_URL]');
10+
}
11+
12+
if (!fs.existsSync(installDir)) {
13+
util._exec('git clone '+ githubUrl + ' ' + installDir);
14+
}
15+
16+
process.chdir(installDir);
17+
util._exec('git fetch origin');
18+
util._exec('git reset --hard origin/master');
19+
util._exec('git clean --force -d');
20+
util._exec('yarn --check-files');
21+
util._exec('npm run build');
22+
util._exec('yalc publish');
23+
24+
process.chdir(ORIG_DIR);
25+
}
26+
27+
if (require.main === module) {
28+
publishYalcPackage(process.argv[2], process.argv[3])
29+
}
30+
31+
module.exports = publishYalcPackage;

0 commit comments

Comments
 (0)