Skip to content

Commit bd6e0a6

Browse files
committed
Update
1 parent a0b5188 commit bd6e0a6

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

lib/utils/replace.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {readdir, lstatSync, readdirSync} = require("fs");
1+
const {readdir, lstatSync, readdirSync, createReadStream, createWriteStream} = require("fs");
22
const {promisify} = require("util");
33
const {join} = require("path");
44
const chalk = require("chalk");
@@ -23,31 +23,46 @@ module.exports = async (directory, options) => {
2323

2424
dir.forEach(element => {
2525
if (element.isDirectory()) return loopDeep(element.name);
26-
parseAndCreateFile();
26+
parseAndCreateFile(join(directory, element.name));
2727
})
2828
} else {
2929
throw new Error(`The path enter is not a directory ${chalk.red(directory)}`);
3030
}
3131

32+
/**
33+
*
34+
* @param {String} dirToLoop
35+
*/
3236
function loopDeep(dirToLoop) {
3337
functionHandler.subFolder.push(dirToLoop);
3438

3539
functionHandler.path = join(directory, `${functionHandler.subFolder.join("/")}`)
3640

37-
console.log(functionHandler.subFolder, functionHandler.path);
3841
const newDir = readdirSync(functionHandler.path, {withFileTypes: true});
3942

4043
newDir.forEach(item => {
4144
if (item.isDirectory()) {
4245
return loopDeep(item.name)
4346
}
44-
45-
console.log(item.name);
46-
parseAndCreateFile();
47+
parseAndCreateFile(join(functionHandler.path, item.name));
4748
})
4849

4950
functionHandler.subFolder = [];
5051
}
5152

52-
function parseAndCreateFile() {};
53+
/**
54+
*
55+
* @param {String} pathToFile
56+
*/
57+
function parseAndCreateFile(pathToFile) {
58+
const fileToRead = createReadStream(pathToFile);
59+
const fileToWrite = createWriteStream();
60+
let data;
61+
62+
fileToRead.on('data', d => {
63+
data = d.toString();
64+
}).on("end", () => {
65+
// console.log(data);
66+
});
67+
};
5368
};

0 commit comments

Comments
 (0)