Skip to content

Commit

Permalink
Allow customizing share root of yowasp-pack-resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jul 14, 2024
1 parent 42fbf0d commit f1c77fa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bin/pack-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,23 @@ async function packDirectory(root, urlRoot, genRoot, dirPath = '', indent = 0) {
}

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

const resourceFileName = args[0];
const genDirectory = args[1];
const shareDirectory = args[2];
const shareRoot = args[3] || 'share';

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('')}
${shareRoot}: ${(await packDirectory(shareDirectory, `./${shareRoot}`, genDirectory, '', 1)).flat(Infinity).join('')}
};
`;
else
Expand Down

0 comments on commit f1c77fa

Please sign in to comment.