express-to-lambda
Version:
Simple package for converting your express application to an AWS Lambda.
19 lines (18 loc) • 609 B
JavaScript
import fs from "fs";
export function commentCode(filePath, regex) {
return new Promise((resolve, reject) => {
fs.readFile(filePath, "utf8", (err, data) => {
if (err)
return reject(err);
const commentedData = data.replace(regex, (match) => match
.split("\n")
.map((line) => `// ${line}`)
.join("\n"));
fs.writeFile(filePath, commentedData, "utf8", (err) => {
if (err)
return reject(err);
resolve(undefined);
});
});
});
}