forked from reTHINK-project/dev-service-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
56 lines (40 loc) · 1.27 KB
/
setup.js
File metadata and controls
56 lines (40 loc) · 1.27 KB
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 fs = require('fs');
var packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'));
var structure = {
src: ['configs', 'jsons', 'utils', 'modules', packageJSON.name + '.js'],
test: [packageJSON.name + '.spec.js']
};
// Create the directory structure
for (var dir in structure) {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
structure[dir].forEach(function(value) {
var currentDir = './' + dir;
if (value.indexOf('.') !== -1) {
var file = currentDir + '/' + value;
if (!fs.existsSync(file)) {
fs.writeFile(file, '');
}
} else {
currentDir += '/' + value;
if (!fs.existsSync(currentDir)) {
fs.mkdirSync(currentDir);
}
}
});
}
// Create the index html for testing
var html = '<!DOCTYPE html><html>' +
'<head>' +
'<title>' + packageJSON.name + ' - ' + packageJSON.version + '</title>' +
'</head>' +
'<body>' +
'<h2>' + packageJSON.description + '</h2>' +
'<script src="vendor/system.js"></script>' +
'<script src="config.js"></script>' +
'<script>System.import("' + packageJSON.name + '");</script>' +
'</body></html>';
if (!fs.existsSync('index.html')) {
fs.writeFile('index.html', html);
}