Skip to content

Commit

Permalink
fix(Keyboard): Fixes an issue where random sounds don't properly expo…
Browse files Browse the repository at this point in the history
…rt. Closes #2965
  • Loading branch information
Alex Anderson committed Jun 16, 2020
1 parent 0f506f4 commit 6fa74e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/imports/addAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "path";
import fs from "fs";
import paths from "../helpers/paths";

let assetDir = path.resolve("./");
export let assetDir = path.resolve("./");

if (process.env.NODE_ENV === "production") {
assetDir = paths.userData;
Expand Down
13 changes: 12 additions & 1 deletion server/imports/missions/export/playSound.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import addAsset from "../../addAsset";
import addAsset, {assetDir} from "../../addAsset";
import fs from "fs";

export default function buildExport(zip, i, type) {
if (i.event === "playSound") {
const args = typeof i.args === "string" ? JSON.parse(i.args) : i.args;
if (!args.sound) return;
const asset = args.sound.asset;

if (asset) {
if (args.type === "random") {
// It's a folder full of stuff. Grab it
const objectLoc = `${assetDir}/assets/${asset}`.replace("//", "/");
if (fs.existsSync(objectLoc) && fs.lstatSync(objectLoc).isDirectory()) {
const files = fs.readdirSync(objectLoc);
files.forEach(file => addAsset(`${asset}/${file}`, zip, type));
return;
}
}
addAsset(asset, zip, type);
}
}
Expand Down

0 comments on commit 6fa74e0

Please sign in to comment.