Skip to content

Commit 3150314

Browse files
committed
add hex md5
1 parent 021963f commit 3150314

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/compilerWrapper.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ export function doCompileAsync(source: {
237237
content?: string,
238238
}, settings: CompilingSettings, callback?: (error: Error | null, result: {
239239
path: string,
240-
output: string,
241-
md5: string,
240+
output: string
242241
} | null) => void): ChildProcess {
243242
const sourcePath = source.path;
244243
const srcDir = dirname(sourcePath);
@@ -258,7 +257,6 @@ export function doCompileAsync(source: {
258257
callback(null, {
259258
path: sourcePath,
260259
output: stdout,
261-
md5: md5(sourceContent),
262260
});
263261
});
264262

@@ -292,7 +290,7 @@ export function compileAsync(source: {
292290

293291
try {
294292

295-
const result = handleCompilerOutput(source.path, settings, data.output, data.md5);
293+
const result = handleCompilerOutput(source.path, settings, data.output);
296294
resolve(result);
297295
} catch (error) {
298296
reject(error);
@@ -360,14 +358,18 @@ export function compile(
360358
settings = Object.assign({}, defaultCompilingSettings, settings);
361359
const cmd = settings2cmd(sourcePath, settings);
362360
const output = execSync(cmd, { input: sourceContent, cwd: curWorkingDir, timeout: settings.timeout, maxBuffer: maxBuffer }).toString();
363-
return handleCompilerOutput(sourcePath, settings, output, md5(sourceContent));
361+
return handleCompilerOutput(sourcePath, settings, output);
362+
}
363+
364+
function calcHexMd5(hex: string) {
365+
const chex = hex.replace(/<([^>]+)>/g, '<>');
366+
return md5(chex);
364367
}
365368

366369
export function handleCompilerOutput(
367370
sourcePath: string,
368371
settings: CompilingSettings,
369372
output: string,
370-
md5: string,
371373
): CompileResult {
372374

373375
const srcDir = dirname(sourcePath);
@@ -380,7 +382,6 @@ export function handleCompilerOutput(
380382
output = output.split(/\r?\n/g).join('\n');
381383
const result: CompileResult = new CompileResult([], []);
382384
result.compilerVersion = compilerVersion(settings.cmdPrefix ? settings.cmdPrefix : findCompiler());
383-
result.md5 = md5;
384385
result.buildType = settings.buildType || BuildType.Debug;
385386
if (output.startsWith('Error:') || output.startsWith('Warning:')) {
386387
Object.assign(result, getErrorsAndWarnings(output, srcDir, sourceFileName));
@@ -422,6 +423,7 @@ export function handleCompilerOutput(
422423
renameSync(outputFilePath, hexFile);
423424
outputFiles['hex'] = hexFile;
424425
result.hex = readFileSync(hexFile, 'utf8');
426+
result.md5 = calcHexMd5(result.hex);
425427
}
426428

427429
if (settings.sourceMap) {

0 commit comments

Comments
 (0)