-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
executable file
·52 lines (39 loc) · 1.39 KB
/
app.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
#!/usr/bin/env node
// make sure we are in this folder to exec the app
process.chdir(__dirname);
var path = require('path');
var home = process.env.HOME;
var fs = require('fs');
var env = path.resolve(home + '/.poeditor.json');
if (fs.existsSync(env)) {
process.argv[2] = env;
}
var pkg = require(__dirname + '/package.json');
var app = require('neasy');
var cli = app.require('cli');
// use the pkg info
app.pkg = pkg;
// arg as absolute route
if (process.argv[2] === undefined) {
return cli.error('Set config.json path as first parameter');
}
// full path
process.argv[2] = path.resolve(process.argv[2]);
if (app.config.xgettext === undefined || app.config.xgettext.path === undefined) {
return cli.error("Configure the xgettext:path in your config.json file!");
}
// replace ~ in case user wants relative path
app.config.xgettext.path = app.config.xgettext.path.replace('~', home);
if (fs.existsSync(app.config.xgettext.path) === false) {
return cli.error("The xgettext:path in your config.json file doesn't exists");
}
if (app.config.xgettext.sources === undefined) {
return cli.error("You should define a sources list");
}
for (var i in app.config.xgettext.sources) {
app.config.xgettext.sources[i] = app.config.xgettext.sources[i].replace('~', home);
}
if (app.config.xgettext.pre !== undefined) {
app.config.xgettext.pre = app.config.xgettext.pre.replace('~', home);
}
app.start();