forked from mbloch/mapshaper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·52 lines (43 loc) · 1.09 KB
/
build
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
#!/usr/bin/env node
var version = require('./package.json').version;
var follow = process.argv.indexOf('-f') > -1;
var requiredModules = [
'mproj',
'buffer',
'iconv-lite',
'fs',
'flatbush',
'rw',
'path',
'd3-dsv'
];
require("catty")({follow: follow})
.addLibrary("src")
.cat("src/gui/mapshaper-gui.js", './www/mapshaper-gui.js')
.prepend("VERSION = '" + version + "';")
.cat("src/mapshaper.js", onCat);
require('browserify')()
.require(requiredModules)
.bundle(function(err, buf) {
if (err) throw err;
write('./www/modules.js', buf);
});
function onCat(err, js) {
if (!err) {
write('./mapshaper.js', js);
write('./www/mapshaper.js', js);
/*
// switch to this if any modules are bundled w/ mapshaper.js
require('browserify')('./mapshaper.js')
.external(requiredModules)
.bundle(function(err, buf) {
if (err) throw err;
write('./www/mapshaper.js', buf);
});
*/
}
}
function write(ofile, contents) {
require('fs').writeFileSync(ofile, contents, 'utf-8');
console.log('Wrote', ofile);
}