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

Commit 6219327

Browse files
author
Derek ROTH
committed
Fix issue NightlyCommit#14 (Windows compatibility)
1 parent b668d5f commit 6219327

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/index.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {NodeVisitor} from "./node-visitor";
55

66
const sha256 = require('crypto-js/sha256');
77
const hex = require('crypto-js/enc-hex');
8+
const process = require('process');
9+
const slash = require('slash');
810

911
const validateOptions = require('schema-utils');
1012

@@ -48,8 +50,14 @@ export default function (this: loader.LoaderContext, source: string) {
4850
let environment: TwingEnvironment = require(environmentModulePath);
4951

5052
if (renderContext === undefined) {
53+
let runtimePath = require.resolve('./runtime');
54+
if (process.platform === 'win32') {
55+
environmentModulePath = slash(environmentModulePath);
56+
runtimePath = slash(runtimePath);
57+
}
58+
5159
let parts: string[] = [
52-
`const {cache, loader, getEnvironment} = require('${require.resolve('./runtime')}');`,
60+
`const {cache, loader, getEnvironment} = require('${runtimePath}');`,
5361
`const env = getEnvironment(require('${environmentModulePath}'));`
5462
];
5563

@@ -89,6 +97,9 @@ return module.exports;})());
8997
parts.push(`loader.addTemplateKey('${className}', '${className}');`);
9098

9199
for (let foundTemplateName of nodeVisitor.foundTemplateNames) {
100+
if (process.platform === 'win32') {
101+
foundTemplateName = slash(foundTemplateName);
102+
}
92103
parts.push(`require('${foundTemplateName}');`);
93104
}
94105

0 commit comments

Comments
 (0)