Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
fix(transpile): normalize and resolve paths always for OS independence
Browse files Browse the repository at this point in the history
normalize and resolve paths always for OS independence
  • Loading branch information
danbucholtz committed Nov 11, 2016
1 parent 6f5d444 commit ca6c889
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function transpileUpdateWorker(event: string, filePath: string, context: BuildCo
return new Promise((resolve, reject) => {
clearDiagnostics(context, DiagnosticsType.TypeScript);

filePath = path.resolve(filePath);
filePath = path.normalize(path.resolve(filePath));

// an existing ts file we already know about has changed
// let's "TRY" to do a single module build for this one file
Expand Down Expand Up @@ -259,16 +259,15 @@ function cleanFileNames(context: BuildContext, fileNames: string[]) {

function writeSourceFiles(fileCache: FileCache, sourceFiles: ts.SourceFile[]) {
for (const sourceFile of sourceFiles) {
fileCache.set(sourceFile.fileName, { path: sourceFile.fileName, content: sourceFile.text });
const fileName = path.normalize(path.resolve(sourceFile.fileName));
fileCache.set(fileName, { path: fileName, content: sourceFile.text });
}
}

function writeTranspiledFilesCallback(fileCache: FileCache, sourcePath: string, data: string, shouldInlineTemplate: boolean) {
sourcePath = path.normalize(sourcePath);
sourcePath = path.normalize(path.resolve(sourcePath));

if (sourcePath.endsWith('.js')) {
sourcePath = sourcePath.substring(0, sourcePath.length - 3) + '.js';

let file = fileCache.get(sourcePath);
if (!file) {
file = { content: '', path: sourcePath };
Expand All @@ -284,7 +283,6 @@ function writeTranspiledFilesCallback(fileCache: FileCache, sourcePath: string,

} else if (sourcePath.endsWith('.js.map')) {

sourcePath = sourcePath.substring(0, sourcePath.length - 7) + '.js.map';
let file = fileCache.get(sourcePath);
if (!file) {
file = { content: '', path: sourcePath };
Expand Down

0 comments on commit ca6c889

Please sign in to comment.