Skip to content

Commit 9ab4022

Browse files
authored
fix: fix build process (#1594)
**Summary** @clangsmith noticed that the build process was not working as expected when following instructions here: https://github.com/sassoftware/vscode-sas-extension/blob/main/CONTRIBUTING.md#get-started. This updates our process to copy files as part of rebuild, and cleanup files when starting build scripts (to make sure we're not holding on to any stale assets) **Testing** - [x] Launched the extension using instructions in CONTRIBUTING.md - [x] Ran `npm run vscode:prepublish` multiple times to make sure things worked (after removing dist files) - [x] Ran `Launch client` followed by `npm run vscode:prepublish` to make sure nothing was broken
1 parent 30a62e7 commit 9ab4022

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

tools/build.mjs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import concurrently from "concurrently";
22
import esbuild from "esbuild";
33
import fs from "fs";
4-
import path from "path";
54

65
console.log("start");
76
const dev = process.argv[2];
@@ -57,13 +56,38 @@ const browserBuildOptions = {
5756
},
5857
};
5958

59+
const copyFiles = () => {
60+
const foldersToCopy = [
61+
{
62+
src: "./server/node_modules/jsonc-parser/lib/umd/impl",
63+
dest: "./server/dist/node/impl",
64+
},
65+
{
66+
src: "./server/node_modules/pyright-internal-node/dist/packages/pyright-internal/typeshed-fallback",
67+
dest: "./server/dist/node/typeshed-fallback",
68+
},
69+
{
70+
src: "./server/src/python/sas",
71+
dest: "./server/dist/node/typeshed-fallback/stubs/sas",
72+
},
73+
{
74+
src: "./client/src/components/notebook/exporters/templates",
75+
dest: "./client/dist/notebook/exporters/templates",
76+
},
77+
];
78+
foldersToCopy.forEach((item) =>
79+
fs.cpSync(item.src, item.dest, { recursive: true }),
80+
);
81+
};
82+
6083
if (process.env.npm_config_webviews || process.env.npm_config_client) {
6184
const ctx = await esbuild.context(
6285
process.env.npm_config_webviews ? browserBuildOptions : nodeBuildOptions,
6386
);
6487
await ctx.rebuild();
6588

6689
if (dev) {
90+
copyFiles();
6791
await ctx.watch();
6892
} else {
6993
await ctx.dispose();
@@ -79,32 +103,7 @@ if (process.env.npm_config_webviews || process.env.npm_config_client) {
79103
name: "node",
80104
},
81105
]);
82-
83-
await result.then(
84-
() => {
85-
const foldersToCopy = [
86-
{
87-
src: "./server/node_modules/jsonc-parser/lib/umd/impl",
88-
dest: "./server/dist/node/impl",
89-
},
90-
{
91-
src: "./server/node_modules/pyright-internal-node/dist/packages/pyright-internal/typeshed-fallback",
92-
dest: "./server/dist/node/typeshed-fallback",
93-
},
94-
{
95-
src: "./server/src/python/sas",
96-
dest: "./server/dist/node/typeshed-fallback/stubs/sas",
97-
},
98-
{
99-
src: "./client/src/components/notebook/exporters/templates",
100-
dest: "./client/dist/notebook/exporters/templates",
101-
},
102-
];
103-
for (const item of foldersToCopy) {
104-
fs.cpSync(item.src, item.dest, { recursive: true });
105-
console.log(`${item.src} was copied to ${item.dest}`);
106-
}
107-
},
108-
() => console.error("Assets failed to build successfully"),
106+
await result.then(copyFiles, () =>
107+
console.error("Assets failed to build successfully"),
109108
);
110109
}

0 commit comments

Comments
 (0)