-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
43 lines (40 loc) · 1.24 KB
/
index.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
/**
* # nodegame-game-template
* Copyright(c) 2018 Stefano Balietti
* MIT Licensed
*
* Handles paths to game templates files.
*
* http://www.nodegame.org
*/
const path = require('path');
// Return the required template.
exports.require = function(file) {
if (file === 'package.json') file = 'package.template.json';
else if (file === 'LICENSE') file = 'LICENSE.template';
else if (file === 'README.md') file = 'README.template.md';
else if (file === '.gitignore') file = '.gitignore.template';
return require(path.resolve(__dirname, file));
};
// Return the path to the required template.
exports.resolve = function(file) {
if (file === 'package.json') {
file = 'package.template.json';
}
else if (file === 'LICENSE') {
file = 'LICENSE.template';
}
else if (file === 'README.md') {
file = 'README.template.md';
}
else if (file === '.gitignore') {
file = '.gitignore.template';
}
else if (file === path.join('private', 'README.md')) {
file = path.join('private.template', 'README.md');
}
else if (file === path.join('private', '.gitkeep')) {
file = path.join('private.template', '.gitkeep');
}
return path.resolve(__dirname, file);
};