Skip to content

Commit fa173a8

Browse files
authored
fix(ng-add): fix v8 import (#189)
* fix(ng-add): fix v8 import * feat(ng-add): change the lib 8 to v8
1 parent 958d581 commit fa173a8

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

schematics/scully/src/ng-add/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ export default (options: Schema): Rule => {
1919
runScullySchematic(options),
2020
]);
2121
};
22-
2322
const addDependencies = () => (tree: Tree, context: SchematicContext) => {
2423
addPackageToPackageJson(tree, '@scullyio/scully', `${scullyVersion}`);
2524
const ngCoreVersionTag = getPackageVersionFromPackageJson(tree, '@angular/core');
2625
if (+ngCoreVersionTag.search(/(\^8|~8)/g) === 0) {
2726
context.logger.info('Install ng-lib for Angular v8');
28-
addPackageToPackageJson(tree, '@scullyio/ng-lib-8', `${scullyComponentVersion}`);
27+
addPackageToPackageJson(tree, '@scullyio/ng-lib-v8', `${scullyComponentVersion}`);
2928
} else {
3029
context.logger.info('Install ng-lib for Angular v9');
3130
addPackageToPackageJson(tree, '@scullyio/ng-lib', `${scullyComponentVersion}`);
@@ -97,9 +96,14 @@ const injectIdleService = () => (tree: Tree, context: SchematicContext) => {
9796
if (appComponent.includes('IdleMonitorService')) {
9897
context.logger.info(`⚠️️ Skipping ${appComponentPath}`);
9998
} else {
100-
const idleImport = `import {IdleMonitorService} from '@scullyio/ng-lib';`;
99+
const ngCoreVersionTag = getPackageVersionFromPackageJson(tree, '@angular/core');
100+
let v8 = '';
101+
if (+ngCoreVersionTag.search(/(\^8|~8)/g) === 0) {
102+
v8 = '-v8';
103+
}
104+
const idleImport = `import {IdleMonitorService} from '@scullyio/ng-lib${v8}';`;
101105
// add
102-
const idImport = `${idleImport} \n ${appComponent}`;
106+
const idImport = `${idleImport}\n${appComponent}`;
103107
const idle = 'private idle: IdleMonitorService';
104108
let output = '';
105109
// check if exist

0 commit comments

Comments
 (0)