This repository was archived by the owner on Oct 7, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtemplates.js
More file actions
69 lines (58 loc) · 1.57 KB
/
templates.js
File metadata and controls
69 lines (58 loc) · 1.57 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const { copyFiles, json, template } = require('mrm-core');
// These files will be overwritten without any confirmation
const files = [
'.github/ISSUE_TEMPLATE/DOCS.md',
'.github/ISSUE_TEMPLATE/SUPPORT.md',
'.github/ISSUE_TEMPLATE.md',
'.github/CODEOWNERS',
'.github/PULL_REQUEST_TEMPLATE.md',
'.github/FUNDING.yml',
'.editorconfig',
'.eslintignore',
'.eslintrc.js',
'.prettierignore',
'.prettierrc.js',
'azure-pipelines.yml',
'babel.config.js',
'commitlint.config.js',
'husky.config.js',
'lint-staged.config.js',
'LICENSE',
];
const testFiles = [
'test/loader.test.js',
'test/options.test.js',
'test/fixtures/fixture.js',
'test/fixtures/foo.js',
'test/helpers/compiler.js',
];
// These files will be created only once
const filesOnce = [
'src/index.js',
'src/cjs.js',
'src/options.json',
'CHANGELOG.md',
];
const dynamicTemplates = [
'.github/CONTRIBUTING.md',
'.github/ISSUE_TEMPLATE/BUG.md',
'.github/ISSUE_TEMPLATE/FEATURE.md',
'.github/ISSUE_TEMPLATE/MODIFICATION.md',
];
module.exports = () => {
const pkg = json('package.json');
const templatesDir = path.resolve(__dirname, '../../templates');
copyFiles(templatesDir, files);
copyFiles(templatesDir, testFiles, { overwrite: false });
for (const tmpl of dynamicTemplates) {
const file = template(
tmpl,
path.join(__dirname, `../../templates/${tmpl}`)
);
file
.apply({ package: pkg.get('name'), repo: pkg.get('repository') })
.save();
}
copyFiles(templatesDir, filesOnce, { overwrite: false });
};