Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sourceText,
ts.ScriptTarget.Latest,
true
);
const [instrumentNgModuleImport] = addImportToModule(
source,
modulePath,
`StoreDevtoolsModule.instrument({ maxAge: ${
options.maxAge
}, logOnly: environment.production })`,
modulePath
);
const srcPath = dirname(options.path as Path);
const environmentsPath = buildRelativePath(
modulePath,
`/${srcPath}/environments/environment`
);
const changes = [
insertImport(
source,
modulePath,
'StoreDevtoolsModule',
'@ngrx/store-devtools'
),
insertImport(source, modulePath, 'environment', environmentsPath),
instrumentNgModuleImport,
];
const recorder = host.beginUpdate(modulePath);
const modulePath = options.module;
if (!modulePath) {
return host;
}
if (!host.exists(modulePath)) {
throw new Error('Specified module does not exist');
}
const text = host.read(modulePath);
if (text === null) {
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
}
const sourceText = text.toString('utf-8');
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
const [instrumentNgModuleImport] = schematics_core_1.addImportToModule(source, modulePath, `StoreDevtoolsModule.instrument({ maxAge: ${options.maxAge}, logOnly: environment.production })`, modulePath);
const srcPath = core_1.dirname(options.path);
const environmentsPath = schematics_core_1.buildRelativePath(modulePath, `/${srcPath}/environments/environment`);
const changes = [
schematics_core_1.insertImport(source, modulePath, 'StoreDevtoolsModule', '@ngrx/store-devtools'),
schematics_core_1.insertImport(source, modulePath, 'environment', environmentsPath),
instrumentNgModuleImport,
];
const recorder = host.beginUpdate(modulePath);
for (const change of changes) {
if (change instanceof schematics_core_1.InsertChange) {
recorder.insertLeft(change.pos, change.toAdd);
}
}
host.commitUpdate(recorder);
return host;
};
}