dist-build.js
888 Bytes
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
const { promises: fs } = require("fs")
const path = require("path")
async function copyDir(src, dest) {
await fs.mkdir(dest, { recursive: true });
let entries = await fs.readdir(src, { withFileTypes: true });
let ignore = [
'node_modules',
'dist',
'src',
'.github',
'.browserslistrc',
'.editorconfig',
'.gitattributes',
'.gitignore',
'.jscsrc',
'.jshintignore',
'.travis.yml',
'composer.json',
'composer.lock',
'package.json',
'package-lock.json',
'phpcs.xml.dist',
'readme.txt'
];
for (let entry of entries) {
if ( ignore.indexOf( entry.name ) != -1 ) {
continue;
}
let srcPath = path.join(src, entry.name);
let destPath = path.join(dest, entry.name);
entry.isDirectory() ?
await copyDir(srcPath, destPath) :
await fs.copyFile(srcPath, destPath);
}
}
copyDir('./', './dist');