This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
forked from 280north/narwhal
-
Notifications
You must be signed in to change notification settings - Fork 16
/
init.js
56 lines (48 loc) · 1.67 KB
/
init.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
var system = require("system");
var fs = require("file");
var json = require("json");
var util = require("util");
var args = require("args");
var parser = exports.parser = new args.Parser();
parser.help('initializes a Narwhal package/project directory');
parser.option('--name', 'name').def("").set();
parser.option('--author', 'author').def("").set();
parser.option('--dependency', 'dependencies').push();
parser.option('--contributor', 'contributors').push();
parser.action(function (options, parentOptions) {
parentOptions.acted = true;
var packageInfo = {};
var path;
if (options.args.length && !/^-/.test(options.args[0]))
path = options.args.shift();
else
path = fs.cwd();
util.update(packageInfo, options);
delete packageInfo.args;
delete packageInfo.command;
path = fs.path(path).absolute();
print(path);
path.join('.tusk').mkdirs();
path.join('bin').mkdirs();
path.join('lib').mkdirs();
var sea = path.join('bin', 'sea');
fs.path(system.prefix).join('bin', 'sea').copy(sea);
sea.chmod(0755);
var activate = path.join('bin', 'activate.bash');
fs.path(system.prefix).join('bin', 'activate.bash')
.copy(activate);
activate.relative().symlink(activate.resolve('activate'));
path.join('README').touch();
path.join('narwhal.conf')
.write('NARWHAL_DEFAULT_ENGINE=' + system.engine);
var packagePath = path.join('package.json');
if (packagePath.isFile())
util.complete(
packageInfo,
json.decode(packagePath.read({charset:'utf-8'}))
);
packagePath.write(
json.encode(packageInfo, null, 4),
{charset:'utf-8'}
);
});