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

Commit b4f96be

Browse files
author
Dimitar Kerezov
committed
refactor(livesync): extract app as constant
1 parent a6b98b3 commit b4f96be

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

Diff for: lib/before-prepareJS.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ module.exports = function ($mobileHelper, $projectData, hookArgs) {
77
const config = {
88
env,
99
platform,
10-
bundle: appFilesUpdaterOptions.bundle,
11-
watch: false
10+
bundle: appFilesUpdaterOptions.bundle
1211
};
1312
const result = config.bundle && runWebpackCompiler.bind(runWebpackCompiler, config, $mobileHelper, $projectData, hookArgs);
1413
return result;

Diff for: lib/before-watchPatterns.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
const { AppDirectoryLocation } = require("./constants");
2+
13
module.exports = function (hookArgs) {
24
if (hookArgs.liveSyncData && hookArgs.liveSyncData.bundle) {
3-
const appDirectoryLocation = "app"; // Might need to get this from config file in the future
4-
const appResourcesDirectoryLocation = "app/App_Resources"; // Might need to get this from config file in the future
55
return (args, originalMethod) => {
66
return originalMethod().then(originalPatterns => {
7-
const appDirectoryLocationIndex = originalPatterns.indexOf(appDirectoryLocation);
7+
const appDirectoryLocationIndex = originalPatterns.indexOf(AppDirectoryLocation);
88
if (appDirectoryLocationIndex !== -1) {
99
originalPatterns.splice(appDirectoryLocationIndex, 1);
1010
}
1111

12-
if (originalPatterns.indexOf(appResourcesDirectoryLocation) === -1) {
13-
originalPatterns.push(appResourcesDirectoryLocation);
14-
}
15-
1612
return originalPatterns;
1713
});
1814
};

Diff for: lib/compiler.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { join, resolve: pathResolve } = require("path");
44
const { existsSync } = require("fs");
55
const readline = require("readline");
66
const { messages } = require("../plugins/WatchStateLoggerPlugin");
7-
const ProjectSnapshotGenerator = require("../snapshot/android/project-snapshot-generator");
7+
const { AppDirectoryLocation } = require("./constants");
88

99
let hasBeenInvoked = false;
1010

@@ -88,8 +88,7 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $mobileHelper,
8888
}
8989

9090
if (hookArgs.filesToSync && hookArgs.startSyncFilesTimeout) {
91-
// TODO: Might need to get the "app" constant from config file in the future
92-
hookArgs.filesToSync.push(...message.emittedFiles.map(emittedFile => join("app", emittedFile)));
91+
hookArgs.filesToSync.push(...message.emittedFiles.map(emittedFile => join(AppDirectoryLocation, emittedFile)));
9392
hookArgs.startSyncFilesTimeout();
9493
}
9594
}

Diff for: lib/constants.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
AppDirectoryLocation: "app"
3+
};

0 commit comments

Comments
 (0)