prettier support
This commit is contained in:
20
lib/build.js
20
lib/build.js
@@ -7,7 +7,8 @@ const esbuild_1 = require("esbuild");
|
||||
const fs_1 = require("fs");
|
||||
const paths_1 = require("./paths");
|
||||
const readmeta_1 = __importDefault(require("./readmeta"));
|
||||
function default_1(name, watchCallback = false) {
|
||||
const prettier_1 = require("prettier");
|
||||
function default_1(name, watchCallback = false, PrettierConfig) {
|
||||
//read meta file
|
||||
let [metaJson, metaString] = (0, readmeta_1.default)(name);
|
||||
let path = (0, paths_1.ScriptPath)(name);
|
||||
@@ -35,7 +36,8 @@ function default_1(name, watchCallback = false) {
|
||||
error = result.error;
|
||||
}
|
||||
else if (result.content) {
|
||||
(0, fs_1.writeFileSync)(pathDist, metaString + result.content);
|
||||
let content = (0, prettier_1.format)(metaString + result.content, PrettierConfig === null ? undefined : PrettierConfig);
|
||||
(0, fs_1.writeFileSync)(pathDist, content);
|
||||
}
|
||||
else {
|
||||
console.error(name, 'No output');
|
||||
@@ -51,7 +53,8 @@ function default_1(name, watchCallback = false) {
|
||||
error = result.error;
|
||||
}
|
||||
else if (result.content) {
|
||||
(0, fs_1.writeFileSync)(pathDist, metaString + result.content);
|
||||
let content = (0, prettier_1.format)(metaString + result.content, PrettierConfig === null ? undefined : PrettierConfig);
|
||||
(0, fs_1.writeFileSync)(pathDist, content);
|
||||
}
|
||||
else {
|
||||
console.error(name, 'No output');
|
||||
@@ -132,17 +135,6 @@ function runEsbuild(opts, watchCallback, toWatch = false) {
|
||||
};
|
||||
}
|
||||
}
|
||||
// //only remove the filename comments if there's only 1 file
|
||||
// function clearFilenameComments(content: string): string {
|
||||
// let regexp = new RegExp(`//\\s*${ScriptBase}/.*(?:\\n|$)`, 'g')
|
||||
// let matches = content.match(regexp)
|
||||
// if (matches) {
|
||||
// if (matches.length === 1) {
|
||||
// content = content.replace(regexp, '')
|
||||
// }
|
||||
// }
|
||||
// return content
|
||||
// }
|
||||
//remove all filename comments
|
||||
function clearFilenameComments(content) {
|
||||
let regexp = new RegExp(`//\\s*${paths_1.ScriptBase}/.*(?:\\n|$)`, 'g');
|
||||
|
||||
Reference in New Issue
Block a user