-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hook): handle node module path os agnostically (#114)
* fix(hook): detemine hook name path separator agnostically Former `hook` name determination was a simple regex using *nix style path separator `/`, using `path.basename`, the required last part gets returned, independent of an os specific path separator. * fix(hook): correctly escape rendered `node_modules_path` string
- Loading branch information
1 parent
32edf9c
commit 26b5fa7
Showing
2 changed files
with
4 additions
and
5 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,10 +1,9 @@ | ||
const fs = require('fs') | ||
const resolve = require('path').resolve | ||
const path = require('path') | ||
const {resolve, join} = require('path') | ||
|
||
exports.generatedMessage = 'Generated by ghooks. Do not edit this file.' | ||
|
||
exports.content = fs | ||
.readFileSync(resolve(`${__dirname}/hook.template.raw`), 'UTF-8') | ||
.replace('{{generated_message}}', exports.generatedMessage) | ||
.replace('{{node_modules_path}}', path.join(process.cwd(), '..')) | ||
.replace('{{node_modules_path}}', join(process.cwd(), '..').replace(/\\/g, '\\')) |
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