forked from RussCoder/djvujs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
48 lines (37 loc) · 1.22 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
/**
* Used in npm scripts to copy files
*/
'use strict';
const fs = require('fs');
async function copy() {
const buildFolder = 'build/';
const extensionFolder = 'extension/dist/'
if (!fs.existsSync(buildFolder)) fs.mkdirSync(buildFolder);
if (!fs.existsSync(extensionFolder)) fs.mkdirSync(extensionFolder);
const copyFile = (path) => {
const fileName = path.split('/').at(-1);
fs.copyFileSync(path, buildFolder + fileName);
fs.copyFileSync(path, extensionFolder + fileName);
}
copyFile('viewer/dist/djvu_viewer.js');
copyFile('library/dist/djvu.js');
console.info('Dist files are copied to the ./build/ and ./extension/ directories');
}
async function prepareManifest(v = 2) {
fs.copyFileSync(`./extension/manifest_v${v}.json`, `./extension/manifest.json`);
console.info(`Copied manifest_v${v} to manifest.json`);
}
async function main() {
const command = process.argv[2];
switch (command) {
case 'copy':
return await copy();
case 'v2':
return prepareManifest(2);
case 'v3':
return prepareManifest(3);
default:
throw new Error('Unsupported command: ' + command);
}
}
void main();