@kubiklabs/wasmkit
Version:
Wasmkit is a development environment to compile, deploy, test, run cosmwasm contracts on different networks.
25 lines (24 loc) • 1.04 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertDirChildren = void 0;
const path_1 = __importDefault(require("path"));
const errors_1 = require("../internal/core/errors");
const errors_list_1 = require("../internal/core/errors-list");
function normalizePaths(mainPath, paths) {
return paths.map(n => path_1.default.relative(mainPath, n));
}
function assertDirChildren(dir, scriptNames) {
const normalized = normalizePaths(".", scriptNames);
const nonScriptPaths = normalized
.filter(scriptName => !path_1.default.relative(".", scriptName).startsWith(dir));
if (nonScriptPaths.length !== 0) {
throw new errors_1.WasmkitError(errors_list_1.ERRORS.BUILTIN_TASKS.SCRIPTS_OUTSIDE_SCRIPTS_DIRECTORY, {
scripts: nonScriptPaths
});
}
return normalized;
}
exports.assertDirChildren = assertDirChildren;