Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed merge conflict
  • Loading branch information
avelynhc committed Sep 13, 2023
2 parents 0f155cf + 628a1f8 commit 072cc8c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/helper/convertToHTML.ts
Expand Up @@ -20,7 +20,10 @@ ${body}
</html>`;

htmlFs.writeFile(`${outputFolder}/${title}.html`, result, function (err: any) {
if (err) console.error(err);
if (err) {
console.error(err);
process.exit(-1);
}
});
console.log(`${title}.html is created successfully!`);
};
2 changes: 1 addition & 1 deletion src/helper/readFile.ts
Expand Up @@ -16,8 +16,8 @@ module.exports.readFile = function (inputPath: string, cssLink: string, selected
.join("");
} catch (err) {
console.error(err);
process.exit(-1);
}

html.convertToHTML(title, cssLink, body, selectedLang, outputFolder);
return title;
};
27 changes: 16 additions & 11 deletions src/helper/readFolder.ts
Expand Up @@ -2,16 +2,21 @@ import readFolderFs from "fs";
const fileModule = require("./readFile");

module.exports.readFolder = function (path: string, cssLink: string, selectedLang: string, outputFolder: string) {
readFolderFs.readdir(path, function (err: any, files: any[]) {
if (err) return console.log(err);
const textFiles:any[] = files.filter(file => file.split('.').pop()==='txt');
textFiles.forEach(function (file) {
fileModule.readFile(
`${path}/${file}`,
cssLink,
selectedLang,
outputFolder
);
try {
readFolderFs.readdir(path, function (err: any, files: any[]) {
if (err) return console.log(err);
const textFiles:any[] = files.filter(file => file.split('.').pop()==='txt');
textFiles.forEach(function (file) {
fileModule.readFile(
`${path}/${file}`,
cssLink,
selectedLang,
outputFolder
);
});
});
});
} catch (error) {
console.error(error);
process.exit(-1);
}
};
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -53,7 +53,7 @@ const selectedLang:string = argv.lang;
fs.stat(argv.input, (err: any, stats: { isDirectory: () => any; isFile: () => any; }) => {
if (err) {
console.error(err);
return;
process.exit(-1);
}

if (stats.isDirectory()) {
Expand All @@ -62,5 +62,6 @@ fs.stat(argv.input, (err: any, stats: { isDirectory: () => any; isFile: () => an
file.readFile(argv.input, cssLink, selectedLang, outputFolder);
} else {
console.error("Error: file extension should be .txt");
process.exit(-1);
}
});

0 comments on commit 072cc8c

Please sign in to comment.