-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopyTemplates.js
More file actions
27 lines (24 loc) · 968 Bytes
/
copyTemplates.js
File metadata and controls
27 lines (24 loc) · 968 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
import fsExtra from 'fs-extra';
import path from 'path';
import fs from 'fs';
const excludes = /(dist|node_modules|\.DS_store)\//;
const includes = /templates\//;
const destPath = path.resolve(__dirname, 'dist');
const srcPath = path.resolve(__dirname, 'src');
function copyDirectory(sourcePath) {
fs.readdirSync(sourcePath)
.forEach((filename) => {
const filePath = path.resolve(sourcePath, filename);
if (!excludes.test(filePath)) {
if (fs.statSync(filePath).isDirectory()) {
copyDirectory(filePath);
} else if (includes.test(filePath)) {
const relativePath = filePath.replace(srcPath, '');
const destinationPath = path.join(destPath, relativePath);
console.info(`${filePath.replace(`${__dirname}/`, '')} -> ${destinationPath.replace(`${__dirname}/`, '')}`);
fsExtra.copySync(filePath, destinationPath);
}
}
});
}
copyDirectory(path.resolve(__dirname, 'src'));