@@ -4,12 +4,14 @@ import * as util from "util";
4
4
import { Device } from "nativescript-preview-sdk" ;
5
5
import { PluginComparisonMessages } from "./preview-app-constants" ;
6
6
import { NODE_MODULES_DIR_NAME } from "../../../common/constants" ;
7
+ import { PLATFORMS_DIR_NAME } from "../../../constants" ;
7
8
8
9
export class PreviewAppPluginsService implements IPreviewAppPluginsService {
9
10
private previewAppVersionWarnings : IDictionary < string [ ] > = { } ;
10
11
11
12
constructor ( private $fs : IFileSystem ,
12
13
private $logger : ILogger ,
14
+ private $pluginsService : IPluginsService ,
13
15
private $projectData : IProjectData ) { }
14
16
15
17
public async comparePluginsOnDevice ( data : IPreviewAppLiveSyncData , device : Device ) : Promise < void > {
@@ -91,17 +93,11 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService {
91
93
}
92
94
93
95
private isNativeScriptPluginWithoutNativeCode ( localPlugin : string , platform : string ) : boolean {
94
- return this . isNativeScriptPlugin ( localPlugin ) && ! this . hasNativeCode ( localPlugin , platform ) ;
95
- }
96
-
97
- private isNativeScriptPlugin ( localPlugin : string ) : boolean {
98
- const pluginPackageJsonPath = path . join ( this . $projectData . projectDir , NODE_MODULES_DIR_NAME , localPlugin , "package.json" ) ;
99
- const pluginPackageJsonContent = this . $fs . readJson ( pluginPackageJsonPath ) ;
100
- return pluginPackageJsonContent && pluginPackageJsonContent . nativescript ;
96
+ return this . $pluginsService . isNativeScriptPlugin ( localPlugin , this . $projectData ) && ! this . hasNativeCode ( localPlugin , platform ) ;
101
97
}
102
98
103
99
private hasNativeCode ( localPlugin : string , platform : string ) : boolean {
104
- const nativeFolderPath = path . join ( this . $projectData . projectDir , NODE_MODULES_DIR_NAME , localPlugin , "platforms" , platform . toLowerCase ( ) ) ;
100
+ const nativeFolderPath = path . join ( this . $projectData . projectDir , NODE_MODULES_DIR_NAME , localPlugin , PLATFORMS_DIR_NAME , platform . toLowerCase ( ) ) ;
105
101
return this . $fs . exists ( nativeFolderPath ) && ! this . $fs . isEmptyDir ( nativeFolderPath ) ;
106
102
}
107
103
}
0 commit comments