Skip to content

Commit

Permalink
Merge pull request #1803 from kennyhyun/fix/utils-error-logging
Browse files Browse the repository at this point in the history
Fix/utils error logging
  • Loading branch information
j0k3r committed Jun 18, 2024
2 parents 778338e + 8539948 commit 984d359
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/packagers/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class NPM {
if (!failed && !_.isEmpty(err.stdout)) {
return BbPromise.resolve({ stdout: err.stdout });
}
if (process.env.SLS_DEBUG) {
console.error(`DEBUG: ${err.stdout}\nSTDERR: ${err.stderr}`);
}
}

return BbPromise.reject(err);
Expand Down
3 changes: 3 additions & 0 deletions lib/packagers/yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class Yarn {
if (!failed && !_.isEmpty(err.stdout)) {
return BbPromise.resolve({ stdout: err.stdout });
}
if (process.env.SLS_DEBUG) {
console.error(`DEBUG: ${err.stdout}\nSTDERR: ${err.stderr}`);
}
}

return BbPromise.reject(err);
Expand Down
8 changes: 8 additions & 0 deletions tests/packagers/npm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ jest.mock('../../lib/utils', () => {
});

describe('npm', () => {
const ENV = process.env;

beforeAll(() => {
process.env = { ...ENV, SLS_DEBUG: '*' };
});
beforeEach(() => {
fsMock.readFileSync.mockReturnValue(false);
});
afterAll(() => {
process.env = ENV;
});

it('should return "package-lock.json" as lockfile name', () => {
expect(npmModule.lockfileName).toEqual('package-lock.json');
Expand Down
9 changes: 9 additions & 0 deletions tests/packagers/yarn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ jest.mock('../../lib/utils', () => {
});

describe('yarn', () => {
const ENV = process.env;

beforeAll(() => {
process.env = { ...ENV, SLS_DEBUG: '*' };
});
afterAll(() => {
process.env = ENV;
});

it('should return "yarn.lock" as lockfile name', () => {
expect(yarnModule.lockfileName).toEqual('yarn.lock');
});
Expand Down

0 comments on commit 984d359

Please sign in to comment.