Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from welldsagl/feature/bug#10
Browse files Browse the repository at this point in the history
Fix - Assets are uploaded as 34 byte
  • Loading branch information
marvinpinto authored Dec 18, 2019
2 parents cc5f6ee + 4cdb338 commit 289e532
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/automatic-releases/__tests__/assets/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this should not be overridden
Empty file.
31 changes: 30 additions & 1 deletion packages/automatic-releases/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import fs from 'fs';
import {generateChangelogFromParsedCommits} from '../src/utils';
import {generateChangelogFromParsedCommits, octokitLogger} from '../src/utils';

describe('changelog generator', () => {
beforeEach(() => {
Expand Down Expand Up @@ -75,4 +75,33 @@ describe('changelog generator', () => {
const result = generateChangelogFromParsedCommits(payload);
expect(result.trim()).toEqual(expected.trim());
});

it('log of input arguments should not overwrite the original args', () => {
const licenseFile = fs.readFileSync(path.join(__dirname, 'assets', 'LICENSE'), 'utf8');
const jarFile = fs.readFileSync(path.join(__dirname, 'assets', 'test.jar'), 'utf8');

const args = [
{
repoToken: 'repoToken',
automaticReleaseTag: 'automaticReleaseTag',
draftRelease: false,
preRelease: false,
releaseTitle: 'releaseTitle',
file: licenseFile,
},
{
repoToken: 'repoToken',
automaticReleaseTag: 'automaticReleaseTag',
draftRelease: false,
preRelease: false,
releaseTitle: 'releaseTitle',
file: jarFile,
},
];

octokitLogger(...args);

expect(args[0].file).toEqual('this should not be overridden');
expect(args[1].file).toEqual('');
});
});
12 changes: 7 additions & 5 deletions packages/automatic-releases/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ export const octokitLogger = (...args): string => {
return arg;
}

const argCopy = {...arg};

// Do not log file buffers
if (arg.file) {
arg.file = '== raw file buffer info removed ==';
if (argCopy.file) {
argCopy.file = '== raw file buffer info removed ==';
}
if (arg.data) {
arg.data = '== raw file buffer info removed ==';
if (argCopy.data) {
argCopy.data = '== raw file buffer info removed ==';
}

return JSON.stringify(arg);
return JSON.stringify(argCopy);
})
.reduce((acc, val) => `${acc} ${val}`, '');
};

0 comments on commit 289e532

Please sign in to comment.