Skip to content

Commit 2169b51

Browse files
alan-agius4filipesilva
authored andcommitted
build: use rimraf instead of custom rimraf
With this change we replace the custom rimraf implementation in the build script with the rimraf npm package. The main reason for this change is because `dist` can be a symlink when building with bazel but our implementation doesn't that.
1 parent a8ecbc8 commit 2169b51

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

scripts/build.ts

+4-13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as child_process from 'child_process';
1111
import * as fs from 'fs';
1212
import * as glob from 'glob';
1313
import * as path from 'path';
14+
import * as rimraf from 'rimraf';
1415
import { packages } from '../lib/packages';
1516
import buildSchema from './build-schema';
1617

@@ -132,20 +133,10 @@ function _rm(p: string) {
132133
fs.unlinkSync(p);
133134
}
134135

135-
136-
function _rimraf(p: string) {
137-
glob.sync(path.join(p, '**/*'), { dot: true, nodir: true })
138-
.forEach(p => fs.unlinkSync(p));
139-
glob.sync(path.join(p, '**/*'), { dot: true })
140-
.sort((a, b) => b.length - a.length)
141-
.forEach(p => fs.rmdirSync(p));
142-
}
143-
144-
145136
function _clean(logger: logging.Logger) {
146137
logger.info('Cleaning...');
147138
logger.info(' Removing dist/...');
148-
_rimraf(path.join(__dirname, '../dist'));
139+
rimraf.sync(path.join(__dirname, '../dist'));
149140
}
150141

151142

@@ -229,7 +220,7 @@ export default async function(
229220
packageLogger.info(packageName);
230221
const pkg = packages[packageName];
231222
_recursiveCopy(pkg.build, pkg.dist, logger);
232-
_rimraf(pkg.build);
223+
rimraf.sync(pkg.build);
233224
}
234225

235226
logger.info('Merging bazel-bin/ with dist/');
@@ -241,7 +232,7 @@ export default async function(
241232
if (fs.existsSync(bazelBinPath)) {
242233
packageLogger.info(packageName);
243234
_recursiveCopy(bazelBinPath, pkg.dist, logger);
244-
_rimraf(bazelBinPath);
235+
rimraf.sync(bazelBinPath);
245236
}
246237
}
247238

0 commit comments

Comments
 (0)