Fix encoding in postcss-parser build (#8534)

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
authored and GitHub committed 2020-06-12 09:12:42 +08:00
1 parent bc3c4eb25d
commit b3ea679958
2 files changed
+29 -12

No files matched your search

+25 -12
View File
@@ -4,6 +4,7 @@ const chalk = require("chalk");
const execa = require("execa");
const minimist = require("minimist");
const path = require("path");
const fs = require("fs");
const stringWidth = require("string-width");
const bundler = require("./bundler");
@@ -36,21 +37,33 @@ function fitTerminal(input) {
}
async function createBundle(bundleConfig, cache) {
const { output } = bundleConfig;
const { output, target } = bundleConfig;
process.stdout.write(fitTerminal(output));
return bundler(bundleConfig, cache)
.catch((error) => {
console.log(FAIL + "\n");
handleError(error);
})
.then((result) => {
if (result.cached) {
console.log(CACHED);
} else {
console.log(OK);
try {
const { cached } = await bundler(bundleConfig, cache);
if (cached) {
console.log(CACHED);
return;
}
// Files including U+FFEE can't load in Chrome Extension
// `prettier-chrome-extension` https://github.com/prettier/prettier-chrome-extension
// details https://github.com/prettier/prettier/pull/8534
if (target === "universal") {
const file = path.join("dist", output);
const content = fs.readFileSync(file, "utf8");
if (content.includes("\ufffe")) {
throw new Error("Bundled umd file should not have U+FFFE character.");
}
});
}
console.log(OK);
} catch (error) {
console.log(FAIL + "\n");
handleError(error);
}
}
function handleError(error) {