Skip to content

Commit 927aa57

Browse files
piter2k1Piotr Grzesiak
authored andcommitted
Use random temp directory for progress estimator (fix concurrent builds)
1 parent 859c5e3 commit 927aa57

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/cli.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
createBundles,
1212
writeBundles,
1313
} from './rollupBuilds';
14-
import { progressEstimator, cleanDist } from './utils';
14+
import { progressEstimatorBuilder, cleanDist } from './utils';
1515
import {
1616
EXIT_ON_ERROR,
1717
errorAsObjectWithMessage,
@@ -24,6 +24,8 @@ const rollpkg = async () => {
2424
/////////////////////////////////////
2525
// clean dist folder
2626
const cleanDistMessage = 'Cleaning dist folder';
27+
const progressEstimator = await progressEstimatorBuilder();
28+
2729
try {
2830
const clean = cleanDist();
2931
await progressEstimator(clean, cleanDistMessage);

src/utils.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import * as fs from 'fs-extra';
2-
import { resolve } from 'path';
2+
import { resolve, join } from 'path';
3+
import * as os from 'os';
34
import * as readline from 'readline';
4-
import createProgressEstimator from 'progress-estimator';
5-
6-
export const progressEstimator = createProgressEstimator({
7-
storagePath: resolve(__dirname, '.progress-estimator'),
8-
spinner: {
9-
interval: 180,
10-
frames: ['🌎', '🌏', '🌍'],
11-
},
12-
});
5+
import createProgressEstimator, { ProgressEstimator } from 'progress-estimator';
6+
7+
export const createRandomProgressEstimatorTempDir: () => Promise<string> = () =>
8+
fs.mkdtemp(join(os.tmpdir(), 'progress-estimator-'));
9+
10+
export const progressEstimatorBuilder: () => Promise<ProgressEstimator> = async () => {
11+
const tempDirPath = await createRandomProgressEstimatorTempDir();
12+
13+
return createProgressEstimator({
14+
storagePath: tempDirPath,
15+
spinner: {
16+
interval: 180,
17+
frames: ['🌎', '🌏', '🌍'],
18+
},
19+
});
20+
};
1321

1422
export const cleanDist: () => Promise<void> = () => fs.emptyDir('./dist');
1523

0 commit comments

Comments
 (0)