forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelativize.js
executable file
·32 lines (25 loc) · 1017 Bytes
/
relativize.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
const fs = require('fs');
const path = require('path');
const References = require('taskcluster-lib-references');
const build = (input, output, rootUrl) => {
const serializable = JSON.parse(fs.readFileSync(input, {encoding: 'utf8'}));
const refs = References.fromSerializable({serializable});
// write uri-structured data to the root where nginx will serve it
refs.asAbsolute(rootUrl).writeUriStructured({directory: output});
// write out a single `references/references.json` containing the same data
fs.writeFileSync(path.join(output, 'references', 'references.json'), serializable);
};
if (!module.parent) {
if (!process.env.TASKCLUSTER_ROOT_URL) {
console.error('TASKCLUSTER_ROOT_URL is not set');
process.exit(1);
}
const input = process.argv[2];
const output = process.argv[3];
if (!input || !output) {
console.error('usage: node src/main.js <input> <output>');
process.exit(1);
}
build(input, output, process.env.TASKCLUSTER_ROOT_URL);
}
exports.build = build;