Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
language: node_js
node_js:
- "stable"
- "4"
- "20"
script:
- npm test
- HUSKY_IGNORE_CI=true node bin/install
Expand Down
25 changes: 12 additions & 13 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
'use strict'

const fs = require('fs')
const path = require('path')
const mkdirp = require('mkdirp')
const rimraf = require('rimraf')
const tempy = require('tempy')
const installFrom = require('../src/install')
const uninstallFrom = require('../src/uninstall')
import fs from 'fs'
import path from 'path'
import { mkdirp } from 'mkdirp'
import { rimraf } from 'rimraf'
import installFrom from '../src/install.js'
import uninstallFrom from '../src/uninstall.js'

function install(rootDir, dir) {
installFrom(path.join(rootDir, dir))
Expand All @@ -33,8 +30,8 @@ function exists(dir, filePath) {
}

describe('yorkie', () => {
let dir
beforeEach(() => (dir = tempy.directory()))
const dir = path.join(__dirname, 'temp')

afterEach(() => rimraf.sync(dir))

it('should support basic layout', () => {
Expand All @@ -47,7 +44,9 @@ describe('yorkie', () => {

expect(hook).toMatch('#yorkie')
expect(hook).toMatch('cd "."')
expect(hook).toMatch(`node "./node_modules/yorkie/src/runner.js" pre-commit`)
expect(hook).toMatch(
`node "./node_modules/yorkie/src/runner.js" pre-commit`,
)
expect(hook).toMatch('--no-verify')

const prepareCommitMsg = readFile(dir, '.git/hooks/prepare-commit-msg')
Expand Down Expand Up @@ -148,7 +147,7 @@ describe('yorkie', () => {
writeFile(
dir,
'.git/hooks/pre-commit',
'// Generated by ghooks. Do not edit this file.'
'// Generated by ghooks. Do not edit this file.',
)

install(dir, 'node_modules/yorkie')
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test against the latest version of this Node.js version
environment:
nodejs_version: "8"
nodejs_version: "20"

# Install scripts. (runs after repo cloning)
install:
Expand Down
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
19 changes: 12 additions & 7 deletions bin/install.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
'use strict'
#!/user/bin/env node

// Run when package is installed
const path = require('path')
const isCI = require('is-ci')
const installFrom = require('../src/install')
import path from 'path'
import isCI from 'is-ci'
import installFrom from '../src/install.js'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

if (isCI && !process.env.HUSKY_IGNORE_CI && !process.env.YORKIE_IGNORE_CI) {
console.log('CI detected, skipping Git hooks installation')
Expand All @@ -12,13 +16,14 @@ if (isCI && !process.env.HUSKY_IGNORE_CI && !process.env.YORKIE_IGNORE_CI) {

if (process.env.HUSKY_SKIP_INSTALL || process.env.YORKIE_SKIP_INSTALL) {
console.log(
`env variable HUSKY_SKIP_INSTALL is set to ${process.env
.HUSKY_SKIP_INSTALL}, skipping Git hooks installation`
`env variable HUSKY_SKIP_INSTALL is set to ${
process.env.HUSKY_SKIP_INSTALL
}, skipping Git hooks installation`,
)
process.exit(0)
}

console.log('setting up Git hooks')
console.log('yorkie: setting up Git hooks')

const depDir = path.join(__dirname, '..')
installFrom(depDir)
13 changes: 8 additions & 5 deletions bin/uninstall.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
'use strict'
#!/user/bin/env node

// Run when package is uninstalled
const path = require('path')
const uninstallFrom = require('../src/uninstall')
import path from 'path'
import uninstallFrom from '../src/uninstall.js'
import { fileURLToPath } from 'url'

console.log('husky')
console.log('uninstalling Git hooks')
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

console.log('yorkie: uninstalling Git hooks')

const depDir = path.join(__dirname, '..')
uninstallFrom(depDir)
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
transformIgnorePatterns: [],
}
Loading