Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@ interface Options {

export function migrate(options: Options): Rule {
return async (tree: Tree, context: SchematicContext) => {
// Apply default values from schema when not provided by the migration system
const resolvedOptions = {
path: options.path ?? './',
format: options.format ?? true,
};

let allPaths = [];
const basePath = process.cwd();
let pathToMigrate: string | undefined;
if (options.path) {
if (options.path.startsWith('..')) {

if (resolvedOptions.path) {
if (resolvedOptions.path.startsWith('..')) {
throw new SchematicsException(
'Cannot run control flow migration outside of the current project.',
);
}

pathToMigrate = normalizePath(join(basePath, options.path));
pathToMigrate = normalizePath(join(basePath, resolvedOptions.path));
if (pathToMigrate.trim() !== '') {
allPaths.push(pathToMigrate);
}
Expand Down