-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
"$(dirname "$0")/../node_modules/.bin/commitlint" --edit $1 | ||
npm x commitlint -- --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
"$(npm x mdep bin commitlint)" --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,12 @@ const fs = require('fs/promises'); | |
const debug = require('debug')('test'); | ||
const execa = require('execa'); | ||
|
||
// setup git so that we can try commits | ||
beforeAll(async () => { | ||
await execa.command('git config --global user.name deploy-tests'); | ||
await execa.command('git config --global user.email [email protected]'); | ||
}); | ||
|
||
describe('(yarn) test installing the package', () => { | ||
const kFilename = 'deploy-yarn.tgz'; | ||
const cwd = process.cwd(); | ||
|
@@ -120,7 +126,14 @@ describe('(yarn) test installing the package', () => { | |
|
||
test('.husky files content sane', async () => { | ||
const contents = await fs.readFile('.husky/commit-msg', { encoding: 'utf8' }); | ||
expect(contents).toContain('npx --no-install commitlint -e $1'); | ||
expect(contents).toContain('"$(npm x mdep bin commitlint)" --edit $1'); | ||
}); | ||
|
||
test('able to commit with hooks installed', async () => { | ||
await fs.writeFile('.gitignore', 'node_modules\n'); | ||
await execa('git', ['add', '.']); | ||
await expect(execa('git', ['commit', '-m', 'wrong message'])).rejects.toThrow('subject may not be empty'); | ||
await execa('git', ['commit', '-m', 'chore(test): correct message']); | ||
}); | ||
}); | ||
|
||
|
@@ -267,7 +280,7 @@ describe('(pnpm) test installing the package', () => { | |
|
||
test('.husky files content sane', async () => { | ||
const contents = await fs.readFile('.husky/commit-msg', { encoding: 'utf8' }); | ||
expect(contents).toContain('npx --no-install commitlint -e $1'); | ||
expect(contents).toContain('"$(npm x mdep bin commitlint)" --edit $1'); | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const execa = require('execa'); | ||
const fs = require('fs/promises'); | ||
const { resolve } = require('path'); | ||
|
||
exports.command = 'bin [binary]'; | ||
exports.desc = 'return absolute path to bundled bin'; | ||
exports.builder = (yargs) => { | ||
return yargs | ||
.positional('binary', { | ||
describe: 'path to binary dep', | ||
type: 'string', | ||
}) | ||
.strict(false) | ||
.help(); | ||
}; | ||
exports.handler = async (argv) => { | ||
const bin = (await execa('npm', ['bin'], { cwd: resolve(__dirname, '../..') })).stdout; | ||
const path = resolve(bin, argv.binary); | ||
|
||
try { | ||
if ((await fs.stat(path)).isFile()) { | ||
process.stdout.write(`${path}\n`); | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.error('path %s isnt a file', path); | ||
process.exit(128); | ||
} | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error('can\'t locate path %s - %o', path, e); | ||
process.exit(128); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters