Skip to content

Commit e0a920e

Browse files
committed
Translate between win32 and posix paths in errorPusher
1 parent 600e1d8 commit e0a920e

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

dist/main/atom/utils/fs.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
* Wraps fs and path into a nice "consistentPath" API
33
*/
44
"use strict";
5-
/** we work with "/" for all paths (so does the typescript language service) */
65
function consistentPath(filePath) {
76
return filePath.split('\\').join('/');
87
}
98
exports.consistentPath = consistentPath;
109
const path = require("path");
10+
// Atom uses system dependent path separators while Typescript uses /. Unfortunately, we
11+
// needs this to make sure things like lint errors work.
12+
exports.systemPath = path.sep === "\\" ? filePath => filePath.replace(/\//g, "\\") : filePath => filePath;
1113
/**
1214
* Resolves to to an absolute path.
1315
* @param from,to,to,to...

dist/main/errorPusher.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ class ErrorPusher {
99
const errors = [];
1010
for (const fileErrors of this.errors.values()) {
1111
for (const [filePath, diagnostics] of fileErrors) {
12+
const _filePath = utils_1.systemPath(filePath);
1213
for (const diagnostic of diagnostics) {
1314
errors.push({
1415
type: "Error",
1516
text: diagnostic.text,
16-
filePath: filePath,
17+
filePath: _filePath,
1718
range: diagnostic.start ? utils_1.locationsToRange(diagnostic.start, diagnostic.end) : undefined
1819
});
1920
}

lib/main/atom/utils/fs.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
* Wraps fs and path into a nice "consistentPath" API
33
*/
44

5-
/** we work with "/" for all paths (so does the typescript language service) */
65
export function consistentPath(filePath: string): string {
7-
return filePath.split('\\').join('/');
6+
return filePath.split('\\').join('/');
87
}
98

109
import * as path from "path";
1110

11+
// Atom uses system dependent path separators while Typescript uses /. Unfortunately, we
12+
// needs this to make sure things like lint errors work.
13+
export const systemPath: (filePath: string) => string = path.sep === "\\" ? filePath => filePath.replace(/\//g, "\\") : filePath => filePath
14+
1215
/**
1316
* Resolves to to an absolute path.
1417
* @param from,to,to,to...

lib/main/errorPusher.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {debounce} from "lodash"
22
import {Diagnostic} from "typescript/lib/protocol"
33
import {Linter, LinterMessage} from "../typings/linter"
4-
import {locationsToRange} from "./atom/utils"
4+
import {locationsToRange, systemPath} from "./atom/utils"
55

66
/** Class that collects errors from all of the clients and pushes them to the Linter service */
77
export class ErrorPusher {
@@ -38,11 +38,12 @@ export class ErrorPusher {
3838

3939
for (const fileErrors of this.errors.values()) {
4040
for (const [filePath, diagnostics] of fileErrors) {
41+
const _filePath = systemPath(filePath)
4142
for (const diagnostic of diagnostics) {
4243
errors.push({
4344
type: "Error",
4445
text: diagnostic.text,
45-
filePath: filePath,
46+
filePath: _filePath,
4647
range: diagnostic.start ? locationsToRange(diagnostic.start, diagnostic.end) : undefined
4748
})
4849
}

lib/main/utils/fsUtil.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)