MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / buildStart

Function buildStart

packages/vite/src/copyAssetsPlugin.ts:24–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22 output = false;
23 },
24 async buildStart() {
25 // run copy only once even if multiple bundles are generated
26 if (output) {
27 return;
28 }
29 output = true;
30
31 let alphaTabSourceDir = options.alphaTabSourceDir;
32 if (!alphaTabSourceDir) {
33 try {
34 const isEsm = typeof import.meta.url === 'string';
35 if (isEsm) {
36 alphaTabSourceDir = url.fileURLToPath(import.meta.resolve('@coderline/alphatab'));
37 } else {
38 alphaTabSourceDir = require.resolve('@coderline/alphatab');
39 }
40
41 alphaTabSourceDir = path.resolve(alphaTabSourceDir, '..');
42
43 // walk up to package.json
44 while (alphaTabSourceDir) {
45 if (
46 await fs.promises
47 .access(path.join(alphaTabSourceDir, 'package.json'), fs.constants.F_OK)
48 .then(() => true)
49 .catch(() => false)
50 ) {
51 // found package directory
52 alphaTabSourceDir = path.resolve(alphaTabSourceDir, 'dist');
53 break;
54 } else {
55 // reached root
56 const parent = path.resolve(alphaTabSourceDir, '..');
57 if (parent === alphaTabSourceDir) {
58 alphaTabSourceDir = undefined;
59 } else {
60 alphaTabSourceDir = parent;
61 }
62 }
63 }
64 } catch {
65 alphaTabSourceDir = path.join(resolvedConfig.root, 'node_modules/@coderline/alphatab/dist/');
66 }
67 }
68
69 let isValidAlphaTabSourceDir: boolean;
70
71 if (alphaTabSourceDir) {
72 try {
73 await fs.promises.access(path.join(alphaTabSourceDir, 'alphaTab.mjs'), fs.constants.F_OK);
74 isValidAlphaTabSourceDir = true;
75 } catch {
76 isValidAlphaTabSourceDir = false;
77 }
78 } else {
79 isValidAlphaTabSourceDir = false;
80 }
81

Callers

nothing calls this directly

Calls 4

copyFilesFunction · 0.85
errorMethod · 0.65
resolveMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected