fix(yarn): offline integrity hash (#5449)

This commit is contained in:
Rhys Arkins 2020-02-13 06:39:07 +01:00 committed by GitHub
parent 0eb616f876
commit 5d454ca3ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View file

@ -297,7 +297,7 @@ interface ArtifactError {
interface UpdatedArtifcats {
name: string;
contents: string;
contents: string | Buffer;
}
export interface WriteExistingFilesResult {
@ -480,7 +480,7 @@ export async function getAdditionalFiles(
const localModified = upath.join(config.localDir, f);
updatedArtifacts.push({
name: f,
contents: await fs.readFile(localModified, 'utf-8'),
contents: await fs.readFile(localModified),
});
}
}

View file

@ -5,7 +5,7 @@ import { CommitFilesConfig } from './git/storage';
export interface FileData {
name: string;
contents: string;
contents: string | Buffer;
}
export interface GotApiOptions {

View file

@ -31,7 +31,7 @@ export interface File {
/**
* file contents
*/
contents: string;
contents: string | Buffer;
}
interface StorageConfig {
@ -504,10 +504,14 @@ export class Storage {
await this._git.add(file.name);
} else {
fileNames.push(file.name);
await fs.outputFile(
join(this._cwd, file.name),
Buffer.from(file.contents)
);
let contents;
// istanbul ignore else
if (typeof file.contents === 'string') {
contents = Buffer.from(file.contents);
} else {
contents = file.contents;
}
await fs.outputFile(join(this._cwd, file.name), contents);
}
}
// istanbul ignore if

View file

@ -20,7 +20,7 @@ export async function commitFilesToBranch(
// istanbul ignore if
if (is.nonEmptyArray(config.excludeCommitPaths)) {
updatedFiles = updatedFiles.filter(f => {
const filename = f.name === '|delete|' ? f.contents : f.name;
const filename = f.name === '|delete|' ? f.contents.toString() : f.name;
const matchesExcludePaths = config.excludeCommitPaths.some(path =>
minimatch(filename, path, { dot: true })
);