summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar matthewp <matthewp@users.noreply.github.com> 2022-10-06 20:34:12 +0000
committerGravatar fredkbot <fred+astrobot@astro.build> 2022-10-06 20:34:12 +0000
commit6e117180655216d4e019dc3343c1be043556a538 (patch)
tree23c10f05fe213061c77e4e4229a1d64eab80d575
parent49fbc6b6483b665393da0b71b1a5407cf0ec6f23 (diff)
downloadastro-6e117180655216d4e019dc3343c1be043556a538.tar.gz
astro-6e117180655216d4e019dc3343c1be043556a538.tar.zst
astro-6e117180655216d4e019dc3343c1be043556a538.zip
[ci] format
Diffstat (limited to '')
-rw-r--r--packages/astro/src/core/build/static-build.ts2
-rw-r--r--packages/astro/src/core/fs/index.ts59
2 files changed, 29 insertions, 32 deletions
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index b0ba2e888..ee0877a19 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -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';
diff --git a/packages/astro/src/core/fs/index.ts b/packages/astro/src/core/fs/index.ts
index 472a51580..f865ef4a8 100644
--- a/packages/astro/src/core/fs/index.ts
+++ b/packages/astro/src/core/fs/index.ts
@@ -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;
+ 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);
+
+ if (stats.isDirectory()) {
+ fs.rmdirSync(p, options);
+ } else {
+ fs.unlinkSync(p);
}
-}
+};