Skip to content

Commit 90492d2

Browse files
author
fabianmoronzirfas
committed
added concat script
1 parent 23d9612 commit 90492d2

File tree

3 files changed

+891
-5
lines changed

3 files changed

+891
-5
lines changed

bin/concat.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const folders = ['./Array/', './Function/', './Object/', './String/'];
2+
// const testFolder = './Array/';
3+
const fs = require('fs');
4+
const path = require('path');
5+
const cat = require('cat');
6+
const bundlePath = path.resolve(process.cwd(), './index.js');
7+
8+
// clear the file
9+
fs.writeFileSync(path.resolve(process.cwd(), bundlePath), '');
10+
// loop folders
11+
folders.forEach(folder => {
12+
fs.readdir(folder, (err, files) => {
13+
files.forEach(file => {
14+
// console.log(file);
15+
let filePath = path.resolve(process.cwd(), `${folder}${file}`);
16+
// console.log(filePath);
17+
cat(filePath, (error, data)=>{
18+
if(error !== null) {
19+
console.log(error);
20+
process.exit();
21+
}
22+
fs.appendFileSync(bundlePath, `//${file}\n${data}\n`);
23+
});
24+
});
25+
});
26+
27+
});

0 commit comments

Comments
 (0)