@nx/workspace
Version:
21 lines (20 loc) • 735 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkDestination = checkDestination;
/**
* Checks whether the destination folder is valid
*
* - must not be outside the workspace
* - must be a new folder
*
* @param schema The options provided to the schematic
*/
function checkDestination(tree, schema, providedDestination) {
const INVALID_DESTINATION = `Invalid destination: [${providedDestination}]`;
if (providedDestination.includes('..')) {
throw new Error(`${INVALID_DESTINATION} - Please specify explicit path.`);
}
if (tree.children(schema.relativeToRootDestination).length > 0) {
throw new Error(`${INVALID_DESTINATION} - Path is not empty.`);
}
}