Skip to content

Commit

Permalink
Allow using yowasp-pack-resources without a share directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jan 20, 2024
1 parent 4b2f956 commit 91683d3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bin/pack-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,26 @@ async function packDirectory(root, urlRoot, genRoot, dirPath = '', indent = 0) {
}

const args = process.argv.slice(2);
if (args.length !== 3) {
console.error(`Usage: yowasp-pack-resources <resources.js> <gen-directory> <share-directory>`);
if (!(args.length >= 2 && args.length <= 3)) {
console.error(`Usage: yowasp-pack-resources <resources.js> <gen-directory> [<share-directory>]`);
process.exit(1);
}

const resourceFileName = args[0];
const genDirectory = args[1];
const shareDirectory = args[2];

await writeFile(resourceFileName, `\
let output = `\
export const modules = ${(await packModules(genDirectory, './')).flat(Infinity).join('')};
`;
if (shareDirectory)
output += `\
export const filesystem = {
share: ${(await packDirectory(shareDirectory, './share', genDirectory, '', 1)).flat(Infinity).join('')}
};
`);
`;
else
output += `\
export const filesystem = {};
`;
await writeFile(resourceFileName, output);

0 comments on commit 91683d3

Please sign in to comment.