diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index d836e63fa..c38c76375 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -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 diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 diff --git a/package.json b/package.json index 45bcc9401..65ad0a613 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/scripts/clean.js b/scripts/clean.js new file mode 100755 index 000000000..fa1b7884c --- /dev/null +++ b/scripts/clean.js @@ -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()