Allow Knex 2.x with Typescript to be installed via git (#5187)

This commit is contained in:
Ferris 2022-05-20 05:54:36 -04:00 committed by GitHub
parent 211c6a7765
commit 1baeefedf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 6 deletions

View File

@ -110,6 +110,10 @@ jobs:
always-auth: false
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm pack
- run: npm install -g
- name: Test npm git dependency
shell: bash
run: |
mkdir TMP/
echo "{ \"dependencies\": { \"knex\": \"git+file://$(pwd)/\" } }" > TMP/package.json
cd TMP/
npm install --verbose

0
.husky/pre-commit Normal file → Executable file
View File

View File

@ -9,7 +9,7 @@
},
"scripts": {
"build": "npm run build:gitignore && npm run build:ts",
"clean": "git clean -f -X lib/",
"clean": "node scripts/clean.js",
"build:ts": "tsc",
"build:gitignore": "node scripts/update_gitignore_for_tsc_output.js run",
"format": "prettier --write \"{lib,bin,scripts,test}/**/*.js\"",
@ -99,8 +99,7 @@
},
"lint-staged": {
"*.{js,json}": [
"prettier --write",
"git add"
"prettier --write"
]
},
"devDependencies": {

29
scripts/clean.js Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const { execSync } = require("child_process");
function main() {
const repoDir = path.dirname(__dirname)
const gitDir = path.join(repoDir, '.git')
const gitDirExists = doesDirectoryExist(gitDir)
if (!gitDirExists) {
console.log("No .git directory detected so can not clean 'lib/'. Exiting.")
process.exit(0)
}
console.log("Cleaning 'lib/' of outputted files from Typescript compilation ...")
const cmd = 'git clean -f -X lib/'
const output = execSync(cmd, { cwd: repoDir })
console.log(output.toString('utf8'))
console.log('Done')
}
function doesDirectoryExist(p) {
if (fs.existsSync(p)) {
return fs.lstatSync(p).isDirectory()
}
return false
}
main()