Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
fix: tell the {N} CLI to ignore the source dir when watching for changes
Browse files Browse the repository at this point in the history
fixes #584
  • Loading branch information
sis0k0 committed Jun 25, 2018
1 parent e349fa8 commit 6f88a1d
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions lib/before-watchPatterns.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
const { basename } = require("path");
const {
buildEnvData,
getCompilationContext,
} = require("./utils");
const { getAppPathFromProjectData } = require("../projectHelpers");

module.exports = function (hookArgs) {
const { liveSyncData } = hookArgs;
if (!liveSyncData || !liveSyncData.bundle) {
return;
}

const { platforms } = hookArgs;
const { env } = liveSyncData;
return (args, originalMethod) => {
return originalMethod(...args).then(originalPatterns => {
if (!platforms || !platforms.length) {
throw new Error("Target platform should be specified!");
}

const compilationContexts = platforms.map(platform =>
getContext(hookArgs.projectData, platform, env));
const appPath = getAppPathFromProjectData(hookArgs.projectData);
const ignorePattern = `!${appPath}`;

const ignorePatterns = compilationContexts.map(
context => `!${context}`
);

return [...originalPatterns, ...ignorePatterns];
return [...originalPatterns, ignorePattern];
});
};
}

function getContext(projectData, platform, env) {
const fullEnvData = buildEnvData(projectData, platform, env);
return getCompilationContext(projectData.projectDir, fullEnvData);
}

0 comments on commit 6f88a1d

Please sign in to comment.