@bscotch/stitch
Version:
Stitch: The GameMaker Studio 2 Asset Pipeline Development Kit.
38 lines • 1.19 kB
JavaScript
import fs from '../../utility/files.js';
class Gms2PipelineCliAssertionError extends Error {
constructor(message) {
super(message);
this.name = 'Gms2PipelineCliAssertionError';
Error.captureStackTrace(this, this.constructor);
}
}
function assert(claim, message) {
if (!claim) {
throw new Gms2PipelineCliAssertionError(message);
}
}
function getTruthyArgs(args) {
return args.filter((arg) => arg);
}
function assertMutualExclusion(args) {
const truthyArgs = getTruthyArgs(args);
assert(truthyArgs.length <= 1, `Cannot accept these mutually exclusive inputs: ${truthyArgs}`);
}
function assertAtLeastOneTruthy(args) {
const truthyArgs = getTruthyArgs(args);
assert(truthyArgs.length >= 1, `Must have one non-empty inputs. Current non-empty inputs are: ${truthyArgs}`);
}
function assertPathExists(...args) {
for (const arg of args) {
assert(fs.existsSync(arg), `The given path does not exists at: ${arg}`);
}
}
export default {
assertMutualExclusion,
assertAtLeastOneTruthy,
assertPathExists,
Gms2PipelineCliAssertionError,
assert,
getTruthyArgs,
};
//# sourceMappingURL=cli-assert.js.map