From 5d454ca3ff7e6bd56382458e59752c04c1b95f0f Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 13 Feb 2020 06:39:07 +0100 Subject: [PATCH] fix(yarn): offline integrity hash (#5449) --- lib/manager/npm/post-update/index.ts | 4 ++-- lib/platform/common.ts | 2 +- lib/platform/git/storage.ts | 14 +++++++++----- lib/workers/branch/commit.ts | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/manager/npm/post-update/index.ts b/lib/manager/npm/post-update/index.ts index 0f224e373b..f01a731ccc 100644 --- a/lib/manager/npm/post-update/index.ts +++ b/lib/manager/npm/post-update/index.ts @@ -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), }); } } diff --git a/lib/platform/common.ts b/lib/platform/common.ts index e70e17fdbe..e85a0b7c7e 100644 --- a/lib/platform/common.ts +++ b/lib/platform/common.ts @@ -5,7 +5,7 @@ import { CommitFilesConfig } from './git/storage'; export interface FileData { name: string; - contents: string; + contents: string | Buffer; } export interface GotApiOptions { diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts index 0ff4ee9b46..a1e3ad1d49 100644 --- a/lib/platform/git/storage.ts +++ b/lib/platform/git/storage.ts @@ -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 diff --git a/lib/workers/branch/commit.ts b/lib/workers/branch/commit.ts index eeda22b7f8..5fe2bffb32 100644 --- a/lib/workers/branch/commit.ts +++ b/lib/workers/branch/commit.ts @@ -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 }) ); -- GitLab