Skip to content

Commit

Permalink
watch only production node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Plamen5kov committed Feb 3, 2017
1 parent 706a86d commit 82ddf2f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as helpers from "../../common/helpers";
import * as path from "path";
import * as semver from "semver";
import * as fiberBootstrap from "../../common/fiber-bootstrap";
import { NodeModulesDependenciesBuilder } from "../../tools/node-modules/node-modules-dependencies-builder";

let choki = require("chokidar");

class LiveSyncService implements ILiveSyncService {
Expand Down Expand Up @@ -117,11 +119,20 @@ class LiveSyncService implements ILiveSyncService {

private partialSync(syncWorkingDirectory: string, onChangedActions: ((event: string, filePath: string, dispatcher: IFutureDispatcher) => void )[]): void {
let that = this;

let dependenciesBuilder = this.$injector.resolve(NodeModulesDependenciesBuilder, {});
let productionDependencies = dependenciesBuilder.getProductionDependencies(this.$projectData.projectDir);
let pattern = ["app"];

if(this.$options.syncAllFiles) {
pattern.push("package.json");
pattern.push("node_modules");

// watch only production node_module/packages same one prepare uses
for(var index in productionDependencies) {
pattern.push("node_modules/" + productionDependencies[index].name);
}
}

let watcher = choki.watch(pattern, { ignoreInitial: true, cwd: syncWorkingDirectory }).on("all", (event: string, filePath: string) => {
fiberBootstrap.run(() => {
that.$dispatcher.dispatch(() => (() => {
Expand Down

0 comments on commit 82ddf2f

Please sign in to comment.