1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

[TS dashboard] Syntax errors don't kill watcher (#17336)

This commit is contained in:
Elliot Winkler 2023-02-14 11:15:52 -07:00 committed by GitHub
parent 4735978b8d
commit 3ec042fa68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,8 +71,8 @@ async function compileScripts(src: string, dest: string) {
const bundleStream = bundler.bundle(); const bundleStream = bundler.bundle();
bundleStream.pipe(fs.createWriteStream(dest)); bundleStream.pipe(fs.createWriteStream(dest));
bundleStream.on('error', (error: Error) => { bundleStream.on('error', (error: unknown) => {
throw error; console.error(`Couldn't compile scripts: ${error}`);
}); });
await pify(endOfStream(bundleStream)); await pify(endOfStream(bundleStream));
@ -95,7 +95,7 @@ async function compileStylesheets(src: string, dest: string): Promise<void> {
gulp.src(src), gulp.src(src),
sourcemaps.init(), sourcemaps.init(),
gulpDartSass().on('error', (error: unknown) => { gulpDartSass().on('error', (error: unknown) => {
throw error; console.error(`Couldn't compile stylesheets: ${error}`);
}), }),
autoprefixer(), autoprefixer(),
sourcemaps.write(), sourcemaps.write(),
@ -141,16 +141,10 @@ async function copyStaticFiles(src: string, dest: string): Promise<void> {
* @param options.isInitial - Whether this is the first time this function has * @param options.isInitial - Whether this is the first time this function has
* been called (if we are watching for file changes, we may call this function * been called (if we are watching for file changes, we may call this function
* multiple times). * multiple times).
* @param options.isOnly - Whether this will be the only time this function will
* be called (if we are not watching for file changes, then this will never be
* called again).
*/ */
async function rebuild({ async function rebuild({ isInitial = false } = {}): Promise<void> {
isInitial = false, if (isInitial) {
isOnly = false, console.log('Building dependency tree, hang tight...');
} = {}): Promise<void> {
if (isInitial && !isOnly) {
console.log('Running initial build, please wait (may take a bit)...');
} }
if (!isInitial) { if (!isInitial) {
@ -159,7 +153,6 @@ async function rebuild({
await fs.emptyDir(FINAL_BUILD_DIRECTORY_PATH); await fs.emptyDir(FINAL_BUILD_DIRECTORY_PATH);
try {
if (isInitial) { if (isInitial) {
await generateIntermediateFiles(); await generateIntermediateFiles();
} }
@ -176,9 +169,6 @@ async function rebuild({
path.join(APP_DIRECTORY_PATH, 'public'), path.join(APP_DIRECTORY_PATH, 'public'),
FINAL_BUILD_DIRECTORY_PATH, FINAL_BUILD_DIRECTORY_PATH,
); );
} catch (error: unknown) {
console.error(error);
}
} }
/** /**
@ -202,7 +192,7 @@ async function main() {
if (opts.watch) { if (opts.watch) {
const rebuildIgnoringErrors = () => { const rebuildIgnoringErrors = () => {
rebuild().catch((error: Error) => { rebuild().catch((error: unknown) => {
console.error(error); console.error(error);
}); });
}; };
@ -222,8 +212,7 @@ async function main() {
.on('error', (error: unknown) => { .on('error', (error: unknown) => {
console.error(error); console.error(error);
}); });
await rebuild({ isInitial: true, isOnly: false });
} else {
await rebuild({ isInitial: true, isOnly: true });
} }
await rebuild({ isInitial: true });
} }