forked from zeux/meshoptimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
45 lines (38 loc) · 1017 Bytes
/
cli.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
#!/usr/bin/env node
// This file is part of gltfpack and is distributed under the terms of MIT License.
var gltfpack = require('./library.js');
var fs = require('fs');
var cp = require('child_process');
var args = process.argv.slice(2);
var paths = {
"basisu": process.env["BASISU_PATH"],
"toktx": process.env["TOKTX_PATH"],
};
var interface = {
read: function (path) {
return fs.readFileSync(path);
},
write: function (path, data) {
fs.writeFileSync(path, data);
},
execute: function (command) {
var arg = command.split(' ');
var exe = arg.shift();
// perform substitution of command executable with environment-specific paths
exe = paths[exe] || exe;
var ret = cp.spawnSync(exe, arg);
return ret.status == null ? 256 : ret.status;
},
unlink: function (path) {
fs.unlinkSync(path);
},
};
gltfpack.pack(args, interface)
.then(function (log) {
process.stdout.write(log);
process.exit(0);
})
.catch(function (err) {
process.stderr.write(err.message);
process.exit(1);
});