Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should throw if two modules found', () => {
try {
host = new EmptyTree();
findModule(host, 'foo/src/app/bar');
throw new Error('Succeeded, should have failed');
} catch (err) {
expect(err.message).toMatch(/Could not find an NgModule/);
}
});
});
beforeEach(async () => {
tree = new UnitTestTree(new EmptyTree());
tree = await schematicRunner
.runExternalSchematicAsync(
require.resolve('../../collection.json'),
'ng-new',
{
name: 'migration-test',
version: '1.2.3',
directory: '.',
},
tree,
)
.toPromise();
tree.overwrite(tsConfigPath, JSON.stringify(oldTsConfig, null, 2));
});
function createTranslateFiles(langs: string[], creator): HostTree {
const treeSource = new EmptyTree();
langs.forEach(lang => {
creator(treeSource, lang);
});
return treeSource;
}
beforeEach(async () => {
tree = new UnitTestTree(new EmptyTree());
tree = await schematicRunner
.runExternalSchematicAsync(
require.resolve('../../collection.json'),
'ng-new',
{
name: 'migration-test',
version: '1.2.3',
directory: '.',
},
tree,
)
.toPromise();
tree = await schematicRunner
.runExternalSchematicAsync(
require.resolve('../../collection.json'),
'universal',
export function createTranslateFiles(langs: string[], creator, path): HostTree {
const treeSource = new EmptyTree();
langs.forEach(lang => {
creator(treeSource, lang, path);
});
return treeSource;
}
beforeEach(async () => {
tree = new UnitTestTree(new EmptyTree());
tree = await schematicRunner
.runExternalSchematicAsync(
require.resolve('../../collection.json'),
'workspace',
{
name: 'migration-test',
version: '1.2.3',
directory: '.',
},
tree,
)
.toPromise();
tree = await schematicRunner
.runExternalSchematicAsync(
require.resolve('../../collection.json'),
beforeEach(async () => {
tree = new UnitTestTree(new EmptyTree());
tree = await schematicRunner
.runExternalSchematicAsync(
require.resolve('../../collection.json'),
'ng-new',
{
name: 'migration-test',
version: '1.2.3',
directory: '.',
},
tree,
)
.toPromise();
});
run: function (options) {
const { taskOptions, workingDir, emptyHost, collectionName, schematicName, logger } = options;
const ui = this.ui;
const packageManager = config_1.CliConfig.fromGlobal().get('packageManager');
const engineHost = schematics_2.getEngineHost();
engineHost.registerTaskExecutor(node_1.BuiltinTaskExecutor.NodePackage, {
rootDirectory: workingDir,
packageManager: packageManager === 'default' ? 'npm' : packageManager,
});
engineHost.registerTaskExecutor(node_1.BuiltinTaskExecutor.RepositoryInitializer, { rootDirectory: workingDir });
const collection = schematics_2.getCollection(collectionName);
const schematic = schematics_2.getSchematic(collection, schematicName);
const projectRoot = !!this.project ? this.project.root : workingDir;
const preppedOptions = prepOptions(schematic, taskOptions);
const opts = Object.assign({}, taskOptions, preppedOptions);
const tree = emptyHost ? new schematics_1.EmptyTree() : new schematics_1.FileSystemTree(new tools_1.FileSystemHost(workingDir));
const host = of_1.of(tree);
const dryRunSink = new schematics_1.DryRunSink(workingDir, opts.force);
const fsSink = new schematics_1.FileSystemSink(workingDir, opts.force);
let error = false;
const loggingQueue = [];
const modifiedFiles = [];
dryRunSink.reporter.subscribe((event) => {
const eventPath = event.path.startsWith('/') ? event.path.substr(1) : event.path;
switch (event.kind) {
case 'error':
const desc = event.description == 'alreadyExist' ? 'already exists' : 'does not exist.';
ui.writeLine(`error! ${eventPath} ${desc}.`);
error = true;
break;
case 'update':
loggingQueue.push({
beforeEach(async () => {
tree = new UnitTestTree(new EmptyTree());
tree = await schematicRunner.runExternalSchematicAsync(
require.resolve('../../collection.json'), 'ng-new',
{
name: 'migration-test',
version: '1.2.3',
directory: '.',
},
tree,
).toPromise();
tree.overwrite(polyfillsPath, polyfills);
});