mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-29 06:35:53 +00:00
fix src/config.ts
: Remove sort_object
(#152)
Fixed #151 I've tried running manually load and parse `Cargo.lock` and it runs fine until `sort_object` is called. Since `Cargo.lock` is auto-generated and usually sorted, I think there is no need for sorting. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
2656b87321
commit
be7377e68e
3 changed files with 6 additions and 57 deletions
|
@ -172,7 +172,7 @@ export class CacheConfig {
|
|||
}
|
||||
}
|
||||
|
||||
hasher.update(JSON.stringify(sort_object(parsed)));
|
||||
hasher.update(JSON.stringify(parsed));
|
||||
|
||||
parsedKeyFiles.push(cargo_manifest);
|
||||
} catch (_e) { // Fallback to caching them as regular file
|
||||
|
@ -200,7 +200,7 @@ export class CacheConfig {
|
|||
"source" in p || "checksum" in p
|
||||
});
|
||||
|
||||
hasher.update(JSON.stringify(sort_object(packages)));
|
||||
hasher.update(JSON.stringify(packages));
|
||||
|
||||
parsedKeyFiles.push(cargo_lock);
|
||||
} catch (_e) { // Fallback to caching them as regular file
|
||||
|
@ -367,20 +367,3 @@ function sort_and_uniq(a: string[]) {
|
|||
[]
|
||||
);
|
||||
}
|
||||
|
||||
function sort_object(o: any): any {
|
||||
if (Array.isArray(o)) {
|
||||
return o.sort().map(sort_object);
|
||||
} else if (typeof o === 'object' && o != null) {
|
||||
return Object
|
||||
.keys(o)
|
||||
.sort()
|
||||
.reduce(function(a: any, k) {
|
||||
a[k] = sort_object(o[k]);
|
||||
|
||||
return a;
|
||||
}, {});
|
||||
} else {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue