Skip to content

Commit d304758

Browse files
author
Martynas Žilinskas
committed
Fixed relative path.
1 parent 8ab6b62 commit d304758

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

example/dist/hello.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* Generated by main-file-generator */
2-
module.exports.default = require('../build.js').Default;
2+
module.exports.default = require('build.js').Default;

example/dist/world.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* Generated by main-file-generator */
2-
module.exports.default = require('../build.js').World;
2+
module.exports.default = require('build.js').World;

src/generator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export default class Generator {
4343

4444
// Get `require` relative path.
4545
let requireFileFullPath = path.join(process.cwd(), this.config.proxyjs.requireFile);
46-
let requireFileRelativePath = path.relative(fullFilePath, requireFileFullPath).split(path.sep).join('/');
46+
let requireFileRelativePath = path.relative(path.dirname(fullFilePath), requireFileFullPath);
47+
if(path.sep !== "/") {
48+
requireFileRelativePath = requireFileRelativePath.split(path.sep).join('/');
49+
}
4750

4851
console.log(fullFilePath);
4952
//Write to file

0 commit comments

Comments
 (0)