Skip to content
Closed
Show file tree
Hide file tree
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 @@ -79,15 +79,13 @@ function standaloneMigration(tree: Tree, tsconfigPath: string, basePath: string,
let pendingChanges: ChangesByFile;
let filesToRemove: Set<ts.SourceFile>|null = null;

if (options.mode === MigrationMode.toStandalone) {
pendingChanges = toStandalone(sourceFiles, program, printer);
} else if (options.mode === MigrationMode.pruneModules) {
if (options.mode === MigrationMode.pruneModules) {
const result = pruneNgModules(program, host, basePath, rootNames, sourceFiles, printer);
Comment thread
alan-agius4 marked this conversation as resolved.
Outdated
pendingChanges = result.pendingChanges;
filesToRemove = result.filesToRemove;
} else {
throw new SchematicsException(
`Unknown schematic mode ${options.mode}. Cannot run the standalone migration.`);
/** MigrationMode.toStandalone */
pendingChanges = toStandalone(sourceFiles, program, printer);
}

for (const [file, changes] of pendingChanges.entries()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"mode": {
"description": "Operation that should be performed by the migrator",
"type": "string",
"enum": ["convert-to-standalone", "prune-ng-modules"],
Comment thread
alan-agius4 marked this conversation as resolved.
Outdated
"default": "convert-to-standalone",
"x-prompt": {
"message": "Choose the type of migration:",
Expand Down
15 changes: 0 additions & 15 deletions packages/core/schematics/test/standalone_migration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,6 @@ describe('standalone migration', () => {
expect(error).toBe('Cannot run standalone migration outside of the current project.');
});

it('should throw an error if an unknown mode is passed in', async () => {
let error: string|null = null;

writeFile('dir.ts', 'console.log(123)');

try {
await runMigration('does-not-exist', './');
} catch (e: any) {
error = e.message;
}

expect(error).toBe(
'Unknown schematic mode does-not-exist. Cannot run the standalone migration.');
});

it('should throw an error if the passed in path is a file', async () => {
let error: string|null = null;

Expand Down