Skip to content

Commit b499371

Browse files
committed
add prepack script
1 parent 35baadb commit b499371

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

packages/utils/scripts/prepack.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable no-console */
2+
3+
// DO NOT RUN this script yourself!
4+
// This is invoked from the main `prepack.ts` script in `sentry-javascript/scripts/prepack.ts`.
5+
6+
import * as fs from 'fs';
7+
import * as fse from 'fs-extra';
8+
import * as path from 'path';
9+
10+
export function prepack(buildDir: string): boolean {
11+
// copy package-specific assets to build dir
12+
const assetPath = path.resolve('jsPolyfills');
13+
const destinationPath = path.resolve(buildDir, 'jsPolyfills');
14+
try {
15+
if (!fs.existsSync(assetPath)) {
16+
console.error(
17+
"\nERROR: Missing 'packages/utils/jsPolyfills' directory. Please run `yarn build` in the `utils` package before running this script again.",
18+
);
19+
return false;
20+
}
21+
console.log(`Copying jsPolyfills to ${path.relative('../..', destinationPath)}.`);
22+
fse.copySync(assetPath, destinationPath);
23+
} catch (error) {
24+
console.error(`\nERROR: Error while copying jsPolyfills to ${path.relative('../..', destinationPath)}:\n${error}`);
25+
return false;
26+
}
27+
return true;
28+
}

0 commit comments

Comments
 (0)