Skip to content

Commit 6d77673

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 1f231a7 + 1a7bfbf commit 6d77673

File tree

10 files changed

+135
-5
lines changed

10 files changed

+135
-5
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '28 7 * * 4'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
A tool that lets you easily manage git hooks
77

8-
> The package was recently renamed from `simple-pre-commit`. See **Releases** for the `simple-pre-commit` documentation.
8+
> The package was recently renamed from `simple-pre-commit`.
9+
10+
11+
> See **Releases** for the `simple-pre-commit` documentation and changelog
912
1013
- Zero dependency
1114
- Small configuration (1 object in package.json)
@@ -116,11 +119,11 @@ Note that you should manually run `npx simple-git-hooks` **every time you change
116119

117120
### Additional configuration options
118121

119-
You can also add a `.simple-git-hooks.js`, `simple-git-hooks.js`, `.simple-git-hooks.json` or `simple-git-hooks.json` file to the project and write the configuration inside it.
122+
You can also add a `.simple-git-hooks.cjs`, `.simple-git-hooks.js`, `simple-git-hooks.cjs`, `simple-git-hooks.js`, `.simple-git-hooks.json` or `simple-git-hooks.json` file to the project and write the configuration inside it.
120123

121124
This way `simple-git-hooks` configuration in `package.json` will not take effect any more.
122125

123-
`.simple-git-hooks.js` or `simple-git-hooks.js` should look like the following.
126+
`.simple-git-hooks.cjs`, `.simple-git-hooks.js` or `simple-git-hooks.cjs`, `simple-git-hooks.js` should look like the following.
124127

125128
```js
126129
module.exports = {

SECURITY.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| all. | :white_check_mark: |
8+
9+
## Reporting a Vulnerability
10+
11+
drop an email to [email protected]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
"pre-push": "exit 1",
3+
"pre-commit": "exit 1"
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "simple-pre-commit-test-package",
3+
"version": "1.0.0",
4+
"devDependencies": {
5+
"simple-git-hooks": "1.0.0"
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "simple-pre-commit-test-package",
3+
"version": "1.0.0",
4+
"devDependencies": {
5+
"simple-git-hooks": "1.0.0"
6+
}
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
"pre-push": "exit 1",
3+
"pre-commit": "exit 1"
4+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-git-hooks",
3-
"version": "2.4.1",
3+
"version": "2.5.1",
44
"description": "A simple, zero dependency tool for setting up git hooks for small projects",
55
"author": "Mikhail Gorbunov <[email protected]> (toplenboren.github.io)",
66
"main": "simple-git-hooks.js",

simple-git-hooks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ function _getConfig(projectRootPath) {
238238

239239
// every function here should accept projectRootPath as first argument and return object
240240
const sources = [
241+
() => _getConfigFromFile(projectRootPath, '.simple-git-hooks.cjs'),
241242
() => _getConfigFromFile(projectRootPath, '.simple-git-hooks.js'),
243+
() => _getConfigFromFile(projectRootPath, 'simple-git-hooks.cjs'),
242244
() => _getConfigFromFile(projectRootPath, 'simple-git-hooks.js'),
243245
() => _getConfigFromFile(projectRootPath, '.simple-git-hooks.json'),
244246
() => _getConfigFromFile(projectRootPath, 'simple-git-hooks.json'),

simple-git-hooks.test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ const testsFolder = path.normalize(path.join(process.cwd(), '_tests'))
7070
// Correct configurations
7171

7272
const projectWithConfigurationInPackageJsonPath = path.normalize(path.join(testsFolder, 'project_with_configuration_in_package_json'))
73+
const projectWithConfigurationInSeparateCjsPath = path.normalize(path.join(testsFolder, 'project_with_configuration_in_separate_cjs'))
7374
const projectWithConfigurationInSeparateJsPath = path.normalize(path.join(testsFolder, 'project_with_configuration_in_separate_js'))
75+
const projectWithConfigurationInAlternativeSeparateCjsPath = path.normalize(path.join(testsFolder, 'project_with_configuration_in_alternative_separate_cjs'))
7476
const projectWithConfigurationInAlternativeSeparateJsPath = path.normalize(path.join(testsFolder, 'project_with_configuration_in_alternative_separate_js'))
7577
const projectWithConfigurationInSeparateJsonPath = path.normalize(path.join(testsFolder, 'project_with_configuration_in_separate_json'))
7678
const projectWithConfigurationInAlternativeSeparateJsonPath = path.normalize(path.join(testsFolder, 'project_with_configuration_in_alternative_separate_json'))
@@ -129,6 +131,26 @@ test('creates git hooks if configuration is correct from .simple-git-hooks.js',
129131
removeGitHooksFolder(projectWithConfigurationInAlternativeSeparateJsPath)
130132
})
131133

134+
test('creates git hooks if configuration is correct from .simple-git-hooks.cjs', () => {
135+
createGitHooksFolder(projectWithConfigurationInAlternativeSeparateCjsPath)
136+
137+
spc.setHooksFromConfig(projectWithConfigurationInAlternativeSeparateCjsPath)
138+
const installedHooks = getInstalledGitHooks(path.normalize(path.join(projectWithConfigurationInAlternativeSeparateCjsPath, '.git', 'hooks')))
139+
expect(JSON.stringify(installedHooks)).toBe(JSON.stringify({'pre-commit':`#!/bin/sh\nexit 1`, 'pre-push':`#!/bin/sh\nexit 1`}))
140+
141+
removeGitHooksFolder(projectWithConfigurationInAlternativeSeparateCjsPath)
142+
})
143+
144+
test('creates git hooks if configuration is correct from simple-git-hooks.cjs', () => {
145+
createGitHooksFolder(projectWithConfigurationInSeparateCjsPath)
146+
147+
spc.setHooksFromConfig(projectWithConfigurationInSeparateCjsPath)
148+
const installedHooks = getInstalledGitHooks(path.normalize(path.join(projectWithConfigurationInSeparateCjsPath, '.git', 'hooks')))
149+
expect(JSON.stringify(installedHooks)).toBe(JSON.stringify({'pre-commit':`#!/bin/sh\nexit 1`, 'pre-push':`#!/bin/sh\nexit 1`}))
150+
151+
removeGitHooksFolder(projectWithConfigurationInSeparateCjsPath)
152+
})
153+
132154
test('creates git hooks if configuration is correct from simple-git-hooks.js', () => {
133155
createGitHooksFolder(projectWithConfigurationInSeparateJsPath)
134156

@@ -139,7 +161,6 @@ test('creates git hooks if configuration is correct from simple-git-hooks.js', (
139161
removeGitHooksFolder(projectWithConfigurationInSeparateJsPath)
140162
})
141163

142-
143164
test('creates git hooks if configuration is correct from .simple-git-hooks.json', () => {
144165
createGitHooksFolder(projectWithConfigurationInAlternativeSeparateJsonPath)
145166

0 commit comments

Comments
 (0)