-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathconvert.js
50 lines (45 loc) · 1.41 KB
/
convert.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
#!/usr/bin/env node
var psd2fgui = require("./lib.js");
function run(argv) {
if (argv.length == 0) {
console.info('Usage: psd2fgui psdFile [outputFile] [--nopack] [--ignore-font] [#buildId]');
process.exit(0);
}
var psdFile = argv[0];
var outputFile;
var option = 0;
var buildId;
for (var i = 1; i < argv.length; i++) {
var arg = argv[i];
if (arg.indexOf('--') == 0) {
switch (arg.substr(2)) {
case 'nopack':
option |= psd2fgui.constants.NO_PACK;
break;
case 'ignore-font':
option |= psd2fgui.constants.IGNORE_FONT;
break;
default:
console.error('unknown argument: ' + arg);
process.exit(1);
break;
}
}
else if (arg.substr(0,1) == '#') {
buildId = arg.substr(1);
}
else {
if (!outputFile)
outputFile = arg;
else {
console.error('unknown argument: ' + arg);
process.exit(1);
}
}
}
psd2fgui.convert(psdFile, outputFile, option, buildId)
.then(function (buildId) {
console.log('buildId: ' + buildId);
}).catch(console.err);
}
run(process.argv.slice(2));