1 | const path = require('path');
|
2 |
|
3 | const pathExists = require('path-exists');
|
4 | const { copyFiles } = require('mrm-core');
|
5 |
|
6 |
|
7 | const files = [
|
8 | '.github/CODEOWNERS',
|
9 | '.github/PULL_REQUEST_TEMPLATE.md',
|
10 | '.github/CONTRIBUTING.md',
|
11 | '.editorconfig',
|
12 | '.eslintrc.js',
|
13 | '.prettierrc.js',
|
14 | 'azure-pipelines.yml',
|
15 | 'babel.config.js',
|
16 | 'commitlint.config.js',
|
17 | 'husky.config.js',
|
18 | 'lint-staged.config.js',
|
19 | 'LICENSE',
|
20 | ];
|
21 |
|
22 | const testFiles = [
|
23 | 'test/loader.test.js',
|
24 | 'test/options.test.js',
|
25 | 'test/fixtures/fixture.js',
|
26 | 'test/fixtures/foo.js',
|
27 | 'test/helpers/compiler.js',
|
28 | ];
|
29 |
|
30 |
|
31 | const filesOnce = [
|
32 | 'src/index.js',
|
33 | 'src/cjs.js',
|
34 | 'src/options.json',
|
35 | 'CHANGELOG.md',
|
36 | ];
|
37 |
|
38 | module.exports = () => {
|
39 | const templatesDir = path.resolve(__dirname, '../../templates');
|
40 |
|
41 | copyFiles(templatesDir, files);
|
42 |
|
43 | pathExists('./test').then((exists) => {
|
44 | if (!exists) {
|
45 | copyFiles(templatesDir, testFiles, { overwrite: false });
|
46 | }
|
47 | });
|
48 |
|
49 | copyFiles(templatesDir, filesOnce, { overwrite: false });
|
50 | };
|