chore: ensure fs operations in bundle scripts finish in sync (#7218)

Hopefully fixes broken releases
This commit is contained in:
Alessio Gravili
2024-07-18 13:44:26 -04:00
committed by GitHub
parent 00771b1f2a
commit 6d0dfeafc8
4 changed files with 33 additions and 28 deletions

View File

@@ -14,12 +14,12 @@ async function build() {
plugins: [sassPlugin({ css: 'external' })],
})
await fs.rename('dist/prod/esbuildEntry.css', 'dist/prod/styles.css', (err) => {
if (err) {
try {
fs.renameSync('dist/prod/esbuildEntry.css', 'dist/prod/styles.css')
} catch (err) {
console.error(`Error while renaming index.css: ${err}`)
throw err
}
})
console.log('styles.css bundled successfully')
@@ -32,12 +32,12 @@ async function build() {
]
for (const file of filesToDelete) {
await fs.unlink(file, (err) => {
if (err) {
try {
fs.unlinkSync(file)
} catch (err) {
console.error(`Error while deleting ${file}: ${err}`)
throw err
}
})
}
console.log('Files renamed and deleted successfully')

View File

@@ -30,9 +30,13 @@ async function build() {
//external: ['*.svg'],
plugins: [sassPlugin({ css: 'external' })],
})
await fs.rename('dist/field/index.css', 'dist/exports/client/bundled.css', (err) => {
if (err) console.error(`Error while renaming index.css: ${err}`)
})
try {
fs.renameSync('dist/field/index.css', 'dist/exports/client/bundled.css')
} catch (err) {
console.error(`Error while renaming index.css: ${err}`)
throw err
}
console.log('dist/field/bundled.css bundled successfully')

View File

@@ -68,19 +68,20 @@ async function build() {
packages: 'external',
plugins: [sassPlugin({ css: 'external' })],
})
await fs.rename('dist/index.css', 'dist/styles.css', (err) => {
if (err) {
try {
fs.renameSync('dist/index.css', 'dist/styles.css')
} catch (err) {
console.error(`Error while renaming index.css: ${err}`)
throw err
}
})
await fs.unlink('dist/index.js', (err) => {
if (err) {
try {
fs.unlinkSync('dist/index.js')
} catch (err) {
console.error(`Error while deleting index.js: ${err}`)
throw err
}
})
console.log('styles.css bundled successfully')
// Bundle `client.ts`

View File

@@ -1,5 +1,5 @@
import { promises as fs, existsSync } from 'fs'
import path, { join } from 'path'
import { join } from 'path'
import globby from 'globby'
import process from 'node:process'
import chalk from 'chalk'