forked from Planeshifter/deidentify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
80 lines (68 loc) · 2.12 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env node
'use strict';
// MODULES //
var childProcess = require( 'child_process' );
var download = require( 'download' );
var path = require( 'path' );
var fs = require( 'fs' );
// VARIABLES //
var dirPath = path.join( './app', 'stanford-ner-2014-10-26' );
var spawn = childProcess.spawn;
// DOWNLOAD STANFORD NER //
fs.stat( dirPath, function( err, stat ) {
if ( err || !stat.isDirectory() ) {
console.log( '1. Downloading Stanford NER tool' );
download(
'http://nlp.stanford.edu/software/stanford-ner-2014-10-26.zip',
'app',
{ extract: 'true' }
).then( buildExecutables );
} else {
console.log( '1. Done. Stanford NER already downloaded.' );
buildExecutables();
}
});
function buildExecutables() {
console.log( '2. Create Builds.' );
var dirName = __dirname;
var cmd = path.join( dirName, 'script/builder/nwjs-build.sh' );
var args = [
'--name=deidentify',
'--src=' + path.join( dirName, 'app' ),
'--win-icon=' + path.join( dirName, 'app/app.ico' ),
'--target=0 1 2 3 4 5',
'--output-dir=' + path.join( dirName, 'dist' ),
'--build'
];
var build = spawn( cmd, args );
build.stdout.on( 'data', function onStdOut( data ) {
console.log( 'stdout: ' + data );
});
build.stderr.on( 'data', function onStdErr( data ) {
console.log( 'stderr: ' + data );
});
build.on( 'close', function onClose( code ) {
console.log( 'child process exited with code ' + code );
createInstallers();
});
}
/**
* Generates installers for Windows, Linus and MacOS.
*/
function createInstallers() {
console.log( '3. Create installers' );
var cmd = path.join( __dirname, 'script/builder/pack.sh' );
var args = [ '--all', '--config=' + path.join( __dirname, 'config.json' ) ];
var installers = spawn( cmd, args, {
cwd: path.join( __dirname, 'script/builder' )
});
installers.stdout.on( 'data', function onStdOut( data ) {
console.log( 'stdout: ' + data );
});
installers.stderr.on( 'data', function onStdErr( data ) {
console.log( 'stderr: ' + data);
});
installers.on( 'close', function onClose( code ) {
console.log( 'Child process exited with code ' + code );
});
} // end FUNCTION createInstallers()