-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_proposal.js
42 lines (34 loc) · 1.08 KB
/
build_proposal.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache 2.0 License.
import { readdirSync, statSync, readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
import { join } from "path";
const args = process.argv.slice(2);
const getAllFiles = function (dirPath, arrayOfFiles) {
arrayOfFiles = arrayOfFiles || [];
const files = readdirSync(dirPath);
for (const file of files) {
const filePath = join(dirPath, file);
if (statSync(filePath).isDirectory()) {
arrayOfFiles = getAllFiles(filePath, arrayOfFiles);
} else {
arrayOfFiles.push(filePath);
}
}
return arrayOfFiles;
};
const rootDir = args[0];
if (!existsSync(rootDir)){
mkdirSync(rootDir, { recursive: true });
}
const bundlePath = "dist/bundle.json";
const bundle = JSON.parse(readFileSync(bundlePath, "utf-8"));
const proposalPath = join(rootDir, "proposal.json");
const proposal = {
actions: [{
name: "set_js_app",
args: {
bundle
},
}]
}
writeFileSync(proposalPath, JSON.stringify(proposal));