Skip to content

Commit

Permalink
feat(hooks): made hook files executable
Browse files Browse the repository at this point in the history
closes #20
  • Loading branch information
travi committed Apr 18, 2021
1 parent fd3e284 commit cdba44a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/hook-creator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ suite('hook creator', () => {
`#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
${script}`
${script}`,
{mode: 0o755}
);
});
});
3 changes: 2 additions & 1 deletion src/hook-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default async function ({configDirectory, hookName, script}) {
`#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
${script}`
${script}`,
{mode: 0o755}
);
}
6 changes: 5 additions & 1 deletion test/integration/features/step_definitions/config-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import any from '@travi/any';
import makeDir from '../../../../thirdparty-wrappers/make-dir';

export async function assertHookContainsScript(hook, script) {
const hookContents = await fs.readFile(`${process.cwd()}/.husky/${hook}`, 'utf-8');
const pathToHookFile = `${process.cwd()}/.husky/${hook}`;

const hookContents = await fs.readFile(pathToHookFile, 'utf-8');

assert.include(
hookContents,
`#!/bin/sh
. "$(dirname "$0")/_/husky.sh"`
);
assert.include(hookContents, script);
// eslint-disable-next-line no-bitwise
assert.equal((`0${(await fs.stat(pathToHookFile)).mode}` & 0o777).toString(8), '755');
}

Given('husky v5 is installed', async function () {
Expand Down

0 comments on commit cdba44a

Please sign in to comment.