-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.js
42 lines (36 loc) · 1.28 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
/* eslint-disable no-console */
const path = require('path');
const fs = require('fs-extra');
const root = require('rootrequire');
const dist = path.resolve(root, 'dist');
const binname = process.platform === 'win32' ? 'dcraw.exe' : 'dcraw';
const bin = process.platform === 'win32'?
path.resolve(root, 'windows', binname) :
process.platform === 'darwin' ?
path.resolve(root, 'macos', binname) :
path.resolve(root, 'linux', binname);
const file = name => path.resolve(dist, name);
(async () => {
await fs.ensureDir(dist);
await fs.emptyDir(dist);
const pkg = require('./package.json');
await fs.outputJson(file('package.json'), Object.assign({}, pkg, {
name: `${pkg.name}-${process.platform}`,
main: 'index.js',
private: undefined,
os: [ process.platform ],
cpu: [ 'x64' ]
}), { spaces: 2 });
await fs.copy(bin, file(binname));
await fs.copy('./README.md', file('README.md'));
await fs.copy('./src/dcraw.c', file('dcraw.c'));
await fs.outputFile(file('index.js'), `
module.exports = require('path').resolve(__dirname, process.platform === 'win32' ? 'dcraw.exe' : 'dcraw');
`);
})().then(() => {
console.log('building package succeeded');
}).catch(err => {
console.error('building package failed');
console.error(err);
process.exitCode = 1;
});