Skip to content

Commit 4c51120

Browse files
author
Rhys Koedijk
authored
Merge pull request #31 from rhyskoedijk/feature/fix-commit-paths
Normalise file paths
2 parents b0b3098 + 5a3b5fa commit 4c51120

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

task/utils/azureDevOpsClient.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class AzureDevOpsClient {
141141
fs.writeFileSync(suggestion.path, Buffer.from(lines.join('\n')));
142142
}
143143
} catch (e) {
144-
error(`Failed to patch local file with multiple suggestions: ${e}`);
144+
throw new Error(`Failed to patch local file with multiple suggestions: ${e}`);
145145
}
146146
});
147147

@@ -179,7 +179,7 @@ export class AzureDevOpsClient {
179179
this.project,
180180
);
181181
} catch (e) {
182-
error(`Failed to commit codespell suggestions to pull request: ${e}`);
182+
throw new Error(`Failed to commit codespell suggestions to pull request: ${e}`);
183183
}
184184
}
185185

@@ -281,7 +281,7 @@ export class AzureDevOpsClient {
281281
);
282282
});
283283
} catch (e) {
284-
error(`Failed to comment codespell suggestions on pull request: ${e}`);
284+
throw new Error(`Failed to comment codespell suggestions on pull request: ${e}`);
285285
}
286286
}
287287

@@ -323,7 +323,7 @@ export class AzureDevOpsClient {
323323
});
324324
});
325325
} catch (e) {
326-
error(`Failed to process user commands in pull request: ${e}`);
326+
throw new Error(`Failed to process user commands in pull request: ${e}`);
327327
}
328328
}
329329

task/utils/codespellRunner.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'path';
2+
13
import { debug, error, tool, warning, which } from 'azure-pipelines-task-lib/task';
24
import { ToolRunner } from 'azure-pipelines-task-lib/toolrunner';
35
import { IFile, IFileSuggestion } from './types';
@@ -72,7 +74,7 @@ export class CodespellRunner {
7274
const fixedFileMatch = line.match(/FIXED\: (.*)/i);
7375
if (fixedFileMatch) {
7476
fixedFiles.push({
75-
path: fixedFileMatch[1].trim(),
77+
path: path.normalize(fixedFileMatch[1]).trim(),
7678
});
7779
}
7880
const warningMatch = line.match(/WARNING\: (.*)/i);
@@ -162,6 +164,7 @@ export class CodespellRunner {
162164
.split('\n')
163165
.map((p) => p.trim())
164166
.filter((p) => p.length > 0)
167+
.map((p) => path.normalize(p))
165168
: [];
166169
}
167170
}

0 commit comments

Comments
 (0)