-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub3-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub1-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub2-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "sub1-test", | ||
"dependencies": { | ||
"my-dependency": "1.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
const stub = require('sinon').stub | ||
const exec = stub(require('child_process'), 'execSync') | ||
const childProcess = require('child_process') | ||
const exec = stub(childProcess, 'execSync') | ||
|
||
const updateLockfile = require('../../lib/update-lockfile') | ||
const { updateLockfile, commitLockfile } = require('../../lib/update-lockfile') | ||
|
||
const dependency = { | ||
type: 'dependencies', | ||
|
@@ -16,13 +17,18 @@ const prepare = () => { | |
exec.withArgs('git status --porcelain').returns('1') | ||
} | ||
|
||
afterAll(() => { | ||
childProcess.execSync.restore() | ||
}) | ||
|
||
const updateMessage = 'chore(package): update lockfile\n\nhttps://npm.im/greenkeeper-lockfile' | ||
|
||
test('do shrinkwrap for old npm versions', () => { | ||
prepare() | ||
expect.assertions(1) | ||
exec.withArgs('npm --version').returns('2.0.0') | ||
updateLockfile({}, {}) | ||
commitLockfile() | ||
expect(exec.secondCall.calledWith('npm shrinkwrap')).toBeTruthy() | ||
}) | ||
|
||
|
@@ -31,6 +37,7 @@ test('use yarn', () => { | |
expect.assertions(1) | ||
exec.withArgs('npm --version').returns('3.0.0') | ||
updateLockfile(dependency, { yarn: true }) | ||
commitLockfile() | ||
expect(exec.thirdCall.calledWith("yarn add '[email protected]'")).toBeTruthy() | ||
}) | ||
|
||
|
@@ -43,6 +50,7 @@ test('yarn no prefix', () => { | |
exec.withArgs('npm --version').returns('3.0.0') | ||
exec.withArgs('npm5 -v').throws() | ||
updateLockfile(tildeDep, { yarn: true }) | ||
commitLockfile() | ||
expect(exec.thirdCall.calledWith("yarn add '[email protected]'")).toBeTruthy() | ||
}) | ||
|
||
|
@@ -52,6 +60,7 @@ test('use yarn with extra arguments from ENV', () => { | |
process.env.GK_LOCK_YARN_OPTS = '--ignore-engines' | ||
exec.withArgs('npm --version').returns('3.0.0') | ||
updateLockfile(dependency, { yarn: true }) | ||
commitLockfile() | ||
expect(exec.thirdCall.calledWith("yarn add --ignore-engines '[email protected]'")).toBeTruthy() | ||
delete process.env.GK_LOCK_YARN_OPTS | ||
}) | ||
|
@@ -62,6 +71,7 @@ test('use npm', () => { | |
exec.withArgs('npm --version').returns('3.0.0') | ||
exec.withArgs('npm5 -v').throws() | ||
updateLockfile(dependency, { npm: true }) | ||
commitLockfile() | ||
expect(exec.getCall(4).calledWith('npm install -S [email protected]')).toBeTruthy() | ||
}) | ||
|
||
|
@@ -71,6 +81,7 @@ test('use npm v5', () => { | |
exec.withArgs('npm --version').returns('3.0.0') | ||
exec.withArgs('npm5 -v').returns('5.0.0') | ||
updateLockfile(dependency, { npm: true }) | ||
commitLockfile() | ||
expect(exec.getCall(4).calledWith('npm5 install -S [email protected]')).toBeTruthy() | ||
}) | ||
|
||
|
@@ -79,6 +90,7 @@ test('default author', () => { | |
exec.withArgs('npm --version').returns('3.0.0') | ||
expect.assertions(2) | ||
updateLockfile(dependency, { npm: true }) | ||
commitLockfile() | ||
expect(exec.getCall(9).calledWith('git config user.email "[email protected]"')).toBeTruthy() | ||
expect(exec.getCall(10).calledWith('git config user.name "greenkeeperio-bot"')).toBeTruthy() | ||
}) | ||
|
@@ -90,6 +102,7 @@ test('customise author', () => { | |
exec.withArgs('npm --version').returns('3.0.0') | ||
expect.assertions(2) | ||
updateLockfile(dependency, { npm: true }) | ||
commitLockfile() | ||
expect(exec.getCall(9).calledWith('git config user.email "[email protected]"')).toBeTruthy() | ||
expect(exec.getCall(10).calledWith('git config user.name "testbot"')).toBeTruthy() | ||
delete process.env.GK_LOCK_COMMIT_EMAIL | ||
|
@@ -106,6 +119,7 @@ test('tilde prefix', () => { | |
exec.withArgs('npm --version').returns('3.0.0') | ||
exec.withArgs('npm5 -v').throws() | ||
updateLockfile(tildeDep, { yarn: true, npm: true }) | ||
commitLockfile() | ||
expect(exec.thirdCall.calledWith("yarn add 'my-dependency@~1.0.0'")).toBeTruthy() | ||
expect(exec.getCall(4).calledWith('npm install -S --save-prefix="~" [email protected]')).toBeTruthy() | ||
}) | ||
|
@@ -115,6 +129,7 @@ test('no status', () => { | |
exec.withArgs('npm --version').returns('3.0.0') | ||
exec.withArgs('git status --porcelain').returns('') | ||
updateLockfile(dependency, { npm: true }) | ||
commitLockfile() | ||
expect.assertions(1) | ||
expect(exec.callCount).toBe(6) | ||
}) | ||
|
@@ -124,6 +139,7 @@ test('no GK_LOCK_COMMIT_AMEND', () => { | |
expect.assertions(1) | ||
exec.withArgs('npm --version').returns('3.0.0') | ||
updateLockfile(dependency, {}) | ||
commitLockfile() | ||
expect(exec.getCall(9).calledWith(`git commit -m "${updateMessage}"`)).toBeTruthy() | ||
}) | ||
|
||
|
@@ -135,6 +151,7 @@ test('with truthy GK_LOCK_COMMIT_AMEND', () => { | |
process.env.GK_LOCK_COMMIT_AMEND = fixture | ||
exec.withArgs('npm --version').returns('3.0.0') | ||
updateLockfile(dependency, {}) | ||
commitLockfile() | ||
expect(exec.getCall(9).calledWith(`git commit --amend --author="greenkeeperio-bot <[email protected]>" --no-edit`)).toBeTruthy() | ||
}) | ||
delete process.env.GK_LOCK_COMMIT_AMEND | ||
|
@@ -150,6 +167,7 @@ test('with truthy GK_LOCK_COMMIT_AMEND and GK_LOCK_COMMIT_NAME/EMAIL', () => { | |
process.env.GK_LOCK_COMMIT_AMEND = fixture | ||
exec.withArgs('npm --version').returns('3.0.0') | ||
updateLockfile(dependency, {}) | ||
commitLockfile() | ||
expect(exec.getCall(9).calledWith(`git commit --amend --author="Example Person <[email protected]>" --no-edit`)).toBeTruthy() | ||
}) | ||
delete process.env.GK_LOCK_COMMIT_AMEND | ||
|
@@ -165,6 +183,7 @@ test('with falsy GK_LOCK_COMMIT_AMEND', () => { | |
process.env.GK_LOCK_COMMIT_AMEND = fixture | ||
exec.withArgs('npm --version').returns('3.0.0') | ||
updateLockfile(dependency, {}) | ||
commitLockfile() | ||
expect(exec.getCall(9).calledWith(`git commit -m "${updateMessage}"`)).toBeTruthy() | ||
}) | ||
delete process.env.GK_LOCK_COMMIT_AMEND | ||
|