1.6 KB58 lines
Blame
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8const fs = require('fs');
9const path = require('path');
10const util = require('util');
11const exec = util.promisify(require('child_process').exec);
12
13function deleteFolderRecursive(pathToDelete) {
14 if (fs.existsSync(pathToDelete)) {
15 fs.readdirSync(pathToDelete).forEach((file, index) => {
16 const curPath = path.join(pathToDelete, file);
17 if (fs.lstatSync(curPath).isDirectory()) {
18 deleteFolderRecursive(curPath);
19 } else {
20 fs.unlinkSync(curPath);
21 }
22 });
23 fs.rmdirSync(pathToDelete);
24 }
25}
26
27async function build() {
28 try {
29 console.log('Building Extension');
30 let {stdout} = await exec('npm run build-extension');
31 console.log(stdout);
32
33 console.log('Building Webview');
34 let webViewOutput = await exec('npm run build-webview');
35 console.log(webViewOutput.stdout);
36 console.log('Build complete');
37 } catch (err) {
38 console.error(`exec error: ${err}`);
39 }
40}
41
42// Run production build for publishing to the vscode marketplace
43
44// We only want to publish open source builds, not internal ones.
45// Fail if we see facebook-only files in the repo.
46const internalPath = './facebook/README.facebook.md';
47if (fs.existsSync(internalPath)) {
48 console.error(
49 `${internalPath} exists. Make sure you only publish the vscode extension from the external repo.`,
50 );
51 process.exit(1);
52}
53
54process.env.NODE_ENV = 'production';
55console.log('Cleaning dist');
56deleteFolderRecursive('./dist');
57build();
58