[ci] format
This commit is contained in:
parent
49fbc6b648
commit
6e11718065
2 changed files with 31 additions and 34 deletions
|
@ -5,9 +5,9 @@ import path from 'path';
|
|||
import { fileURLToPath } from 'url';
|
||||
import * as vite from 'vite';
|
||||
import { BuildInternals, createBuildInternals } from '../../core/build/internal.js';
|
||||
import { emptyDir, removeDir } from '../../core/fs/index.js';
|
||||
import { prependForwardSlash } from '../../core/path.js';
|
||||
import { isModeServerWithNoAdapter } from '../../core/util.js';
|
||||
import { emptyDir, removeDir } from '../../core/fs/index.js';
|
||||
import { runHookBuildSetup } from '../../integrations/index.js';
|
||||
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||
import { info } from '../logger/core.js';
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath, pathToFileURL } from 'url';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const isWindows = (process.platform === "win32");
|
||||
const isWindows = process.platform === 'win32';
|
||||
|
||||
/** An fs utility, similar to `rimraf` or `rm -rf` */
|
||||
export function removeDir(_dir: URL): void {
|
||||
|
@ -23,13 +23,13 @@ export function emptyDir(_dir: URL, skip?: Set<string>): void {
|
|||
|
||||
try {
|
||||
fs.rmSync(p, rmOptions);
|
||||
} catch(er: any) {
|
||||
if (er.code === "ENOENT") {
|
||||
return
|
||||
} catch (er: any) {
|
||||
if (er.code === 'ENOENT') {
|
||||
return;
|
||||
}
|
||||
// Windows can EPERM on stat. Life is suffering.
|
||||
// From https://github.com/isaacs/rimraf/blob/8c10fb8d685d5cc35708e0ffc4dac9ec5dd5b444/rimraf.js#L294
|
||||
if (er.code === "EPERM" && isWindows) {
|
||||
if (er.code === 'EPERM' && isWindows) {
|
||||
fixWinEPERMSync(p, rmOptions, er);
|
||||
}
|
||||
}
|
||||
|
@ -38,33 +38,30 @@ export function emptyDir(_dir: URL, skip?: Set<string>): void {
|
|||
|
||||
// Taken from https://github.com/isaacs/rimraf/blob/8c10fb8d685d5cc35708e0ffc4dac9ec5dd5b444/rimraf.js#L183
|
||||
const fixWinEPERMSync = (p: string, options: fs.RmDirOptions, er: any) => {
|
||||
try {
|
||||
fs.chmodSync(p, 0o666);
|
||||
} catch (er2: any) {
|
||||
if (er2.code === "ENOENT") {
|
||||
return;
|
||||
try {
|
||||
fs.chmodSync(p, 0o666);
|
||||
} catch (er2: any) {
|
||||
if (er2.code === 'ENOENT') {
|
||||
return;
|
||||
} else {
|
||||
throw er;
|
||||
}
|
||||
else {
|
||||
throw er;
|
||||
}
|
||||
}
|
||||
|
||||
let stats;
|
||||
try {
|
||||
stats = fs.statSync(p);
|
||||
} catch (er3: any) {
|
||||
if (er3.code === "ENOENT") {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
throw er;
|
||||
}
|
||||
}
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
fs.rmdirSync(p, options);
|
||||
}
|
||||
else {
|
||||
fs.unlinkSync(p);
|
||||
|
||||
let stats;
|
||||
try {
|
||||
stats = fs.statSync(p);
|
||||
} catch (er3: any) {
|
||||
if (er3.code === 'ENOENT') {
|
||||
return;
|
||||
} else {
|
||||
throw er;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
fs.rmdirSync(p, options);
|
||||
} else {
|
||||
fs.unlinkSync(p);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue