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

Commit 75a7d83

Browse files
committed
fix: resolve appComponents absolute paths on Windows
Fix #573.
1 parent c27e0db commit 75a7d83

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Diff for: android-app-components-loader.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
module.exports = function(source) {
1+
const { convertSlashesInPath } = require("./projectHelpers");
2+
3+
module.exports = function (source) {
24
this.cacheable();
35
const { modules } = this.query;
4-
const imports = modules.map(m => `require("${m}");`).join("\n");
6+
const imports = modules.map(m => convertSlashesInPath(m))
7+
.map(m => `require("${m}");`).join("\n");
58
const augmentedSource = `
69
if (!global["__snapshot"]) {
710
${imports}

Diff for: projectHelpers.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const isSass = ({ projectDir, packageJson } = {}) => {
3636
packageJson.dependencies &&
3737
packageJson.dependencies.hasOwnProperty(SASS_PLUGIN_NAME)
3838
) || (
39-
packageJson.devDependencies &&
40-
packageJson.devDependencies.hasOwnProperty(SASS_PLUGIN_NAME)
41-
);
39+
packageJson.devDependencies &&
40+
packageJson.devDependencies.hasOwnProperty(SASS_PLUGIN_NAME)
41+
);
4242
};
4343

4444
const getWebpackConfig = (projectDir, env, configPath = "webpack.config.js") => {
@@ -103,6 +103,16 @@ function safeGet(object, property, ...args) {
103103
value;
104104
}
105105

106+
// Convert paths from C:\some\path to C:/some/path in order to be required
107+
function convertSlashesInPath(modulePath) {
108+
if (isWindows) {
109+
modulePath = modulePath.replace(/\\/g, "/");
110+
}
111+
return modulePath;
112+
}
113+
114+
const isWindows = process.platform.startsWith("win32");
115+
106116
module.exports = {
107117
getAppPathFromProjectData,
108118
getAppResourcesPathFromProjectData,
@@ -115,4 +125,5 @@ module.exports = {
115125
isSass,
116126
isTypeScript,
117127
writePackageJson,
128+
convertSlashesInPath
118129
};

0 commit comments

Comments
 (0)