-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.js
executable file
·39 lines (32 loc) · 1 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
'use strict';
const assert = require('assert');
const fs = require('fs');
const eachAsync = require('each-async');
const got = require('got');
const rimraf = require('rimraf');
const stringifyObject = require('stringify-object');
const pkg = require('./package.json');
got('https://spdx.org/licenses/licenses.json', {json: true}, (gotError, json) => {
assert.ifError(gotError);
let array = json.licenses.map(license => license.licenseId);
let files = [
{
path: pkg.main,
contents: JSON.stringify(array, null, ' ')
},
{
path: require('./bower.json').main,
contents: `window.spdxLicenseIds = ${stringifyObject(array, {indent: ' '})};`
}
];
rimraf(pkg.name + '*', removeErr => {
assert.ifError(removeErr);
eachAsync(files, (file, index, next) => {
console.log('Writing... ' + file.path);
fs.writeFile(file.path, file.contents + '\n', next);
}, writeErr => {
assert.ifError(writeErr);
console.log('Build completed.');
});
});
});