MCPcopy Index your code
hub / github.com/codenameone/CodenameOne / materializeBundle

Function materializeBundle

scripts/run-javascript-lifecycle-tests.mjs:96–112  ·  view source on GitHub ↗

* Materialise a bundle into a freshly-created directory so the harness * server can serve it. Accepts either a directory (copied) or one of * the bundled archive shapes (zip / war / jar — unzip-extractable).

(input, dest)

Source from the content-addressed store, hash-verified

94 * the bundled archive shapes (zip / war / jar — unzip-extractable).
95 */
96function materializeBundle(input, dest) {
97 fs.mkdirSync(dest, { recursive: true });
98 const stat = fs.statSync(input);
99 if (stat.isDirectory()) {
100 copyTree(input, dest);
101 return;
102 }
103 const ext = path.extname(input).toLowerCase();
104 if (ext === '.zip' || ext === '.war' || ext === '.jar') {
105 const result = nodeSpawnSync('unzip', ['-qq', input, '-d', dest], { encoding: 'utf8' });
106 if (result.status !== 0) {
107 throw new Error(`unzip failed for ${input}: status=${result.status} stderr=${result.stderr}`);
108 }
109 return;
110 }
111 throw new Error(`Unsupported bundle input: ${input}`);
112}
113
114function copyTree(src, dst) {
115 fs.mkdirSync(dst, { recursive: true });

Callers 1

runBundleFunction · 0.85

Calls 3

copyTreeFunction · 0.85
toLowerCaseMethod · 0.65
isDirectoryMethod · 0.45

Tested by

no test coverage detected