-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
63 lines (54 loc) · 1.99 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const build = require('extra-build');
const owner = 'nodef';
const repo = build.readMetadata('.').name.replace(/\..*/, '');
// Publish root package to NPM, GitHub.
function publishRootPackage(ds, ver, typ) {
var _package = build.readDocument('package.json');
var m = build.readMetadata('.');
m.version = ver;
m.keywords = [...new Set([...m.keywords, 'shell', 'bash'])];
build.writeMetadata('.', m);
var _npmignore = build.readDocument('.npmignore');
var ignore = build.readFileText('.npmignore');
ignore += 'index.cmd\n';
build.writeFileText('.npmignore', ignore);
build.publish('.');
try { build.publishGithub('.', owner); }
catch {}
build.writeDocument(_npmignore);
m.name = m.name.replace(/\.sh$/, '.cmd');
m.version = ver;
m.keywords = [...new Set([...m.keywords, 'windows', 'console'])];
m.main = 'index.cmd';
m.bin = {'extra-cd': 'index.cmd', 'ecd': 'index.cmd'};
build.writeMetadata('.', m);
var _npmignore = build.readDocument('.npmignore');
var ignore = build.readFileText('.npmignore');
ignore += 'index.sh\n';
build.writeFileText('.npmignore', ignore);
var _readme = build.readDocument('README.md');
var txt = build.readFileText('README.md');
txt = txt.replace('https://unpkg.com/extra-cd.sh/', 'https://unpkg.com/extra-cd.cmd/');
build.writeFileText('README.md', txt);
build.publish('.');
try { build.publishGithub('.', owner); }
catch {}
build.writeDocument(_readme);
build.writeDocument(_npmignore);
build.writeDocument(_package);
}
// Publish root package to NPM, GitHub.
function publishRootPackages(ds, ver) {
publishRootPackage(ds, ver, '');
}
// Publish root, sub packages to NPM, GitHub.
function publishPackages(ds) {
var m = build.readMetadata('.');
var ver = build.nextUnpublishedVersion(m.name, m.version);
build.updateGithubRepoDetails({owner, repo, topics: m.keywords});
publishRootPackages(ds, ver);
}
function main(a) {
if (a[2] === 'publish-packages') publishPackages([]);
}
main(process.argv);