Skip to content

Commit 418b72b

Browse files
author
Fatme
authored
Merge pull request #4711 from NativeScript/fatme/fix-plugin-workflow
fix: fix plugin's development workflow
2 parents 3531838 + 2dc7a81 commit 418b72b

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

lib/controllers/prepare-controller.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { hook } from "../common/helpers";
44
import { performanceLog } from "../common/decorators";
55
import { EventEmitter } from "events";
66
import * as path from "path";
7-
import { PREPARE_READY_EVENT_NAME, WEBPACK_COMPILATION_COMPLETE, PACKAGE_JSON_FILE_NAME } from "../constants";
7+
import { PREPARE_READY_EVENT_NAME, WEBPACK_COMPILATION_COMPLETE, PACKAGE_JSON_FILE_NAME, PLATFORMS_DIR_NAME } from "../constants";
88

99
interface IPlatformWatcherData {
1010
webpackCompilerProcess: child_process.ChildProcess;
@@ -20,6 +20,7 @@ export class PrepareController extends EventEmitter {
2020
private $platformController: IPlatformController,
2121
public $hooksService: IHooksService,
2222
private $logger: ILogger,
23+
private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder,
2324
private $platformsDataService: IPlatformsDataService,
2425
private $prepareNativePlatformService: IPrepareNativePlatformService,
2526
private $projectChangesService: IProjectChangesService,
@@ -141,12 +142,15 @@ export class PrepareController extends EventEmitter {
141142

142143
@hook('watchPatterns')
143144
public async getWatcherPatterns(platformData: IPlatformData, projectData: IProjectData): Promise<string[]> {
145+
const pluginsNativeDirectories = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir)
146+
.filter(dep => dep.nativescript)
147+
.map(dep => path.join(dep.directory, PLATFORMS_DIR_NAME, platformData.platformNameLowerCase));
148+
144149
const patterns = [
145150
path.join(projectData.projectDir, PACKAGE_JSON_FILE_NAME),
146151
path.join(projectData.getAppDirectoryPath(), PACKAGE_JSON_FILE_NAME),
147152
path.join(projectData.getAppResourcesRelativeDirectoryPath(), platformData.normalizedPlatformName),
148-
`node_modules/**/platforms/${platformData.platformNameLowerCase}/`
149-
];
153+
].concat(pluginsNativeDirectories);
150154

151155
return patterns;
152156
}

lib/controllers/run-controller.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ export class RunController extends EventEmitter implements IRunController {
302302

303303
try {
304304
if (data.hasNativeChanges) {
305-
if (await this.$prepareNativePlatformService.prepareNativePlatform(platformData, projectData, prepareData)) {
306-
await deviceDescriptor.buildAction();
307-
}
305+
await this.$prepareNativePlatformService.prepareNativePlatform(platformData, projectData, prepareData);
306+
await deviceDescriptor.buildAction();
308307
}
309308

310309
const isInHMRMode = liveSyncInfo.useHotModuleReload && data.hmrData && data.hmrData.hash;

test/controllers/prepare-controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ function createTestInjector(data: { hasNativeChanges: boolean }): IInjector {
4545

4646
injector.register("prepareController", PrepareController);
4747

48+
injector.register("nodeModulesDependenciesBuilder", {
49+
getProductionDependencies: () => (<any>[])
50+
});
51+
4852
const prepareController: PrepareController = injector.resolve("prepareController");
4953
prepareController.emit = (eventName: string, eventData: any) => {
5054
emittedEventNames.push(eventName);

0 commit comments

Comments
 (0)