diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..580950b --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,41 @@ +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: "34 4 * * 5" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ javascript ] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 3ac6dd6..d071888 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,46 +1,18 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI +name: CI on: push: - branches: - - main - - master - pull_request: - branches: - - main - - master - schedule: - - cron: '0 2 * * *' - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node-version: [8, 10, 12, 14, 16] - os: [ubuntu-latest, windows-latest, macos-latest] + branches: [ master ] - steps: - - name: Checkout Git Source - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i + pull_request: + branches: [ master ] - - name: Continuous Integration - run: npm run ci + workflow_dispatch: {} - - name: Code Coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} +jobs: + Job: + name: Node.js + uses: artusjs/github-actions/.github/workflows/node-test.yml@v1 + with: + os: 'ubuntu-latest, macos-latest, windows-latest' + version: '8, 10, 12, 14, 16, 18' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1612587 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,17 @@ +name: Release + +on: + push: + branches: [ master ] + + workflow_dispatch: {} + +jobs: + release: + name: Node.js + uses: artusjs/github-actions/.github/workflows/node-release.yml@v1 + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} + with: + checkTest: false diff --git a/.gitignore b/.gitignore index 6a0d94c..c6897ad 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ npm-debug.log coverage/ test/fixtures/ts/**/*.js .DS_Store +package-lock.json diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 5e17c6d..0000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -fengmk2 (https://fengmk2.com) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..04b0a95 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog + +## [1.5.4](https://github.com/node-modules/runscript/compare/v1.5.3...v1.5.4) (2024-01-11) + + +### Bug Fixes + +* add check cmd on Windows ([#21](https://github.com/node-modules/runscript/issues/21)) ([ff495d9](https://github.com/node-modules/runscript/commit/ff495d9163a0e655f8aebf1c466021f20ad7274a)) diff --git a/index.js b/index.js index 799aece..79e217c 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,23 @@ const is = require('is-type-of'); const assert = require('assert'); const path = require('path'); const spawn = require('child_process').spawn; +const spawnSync = require('child_process').spawnSync; + +function isCmd() { + if (process.platform !== 'win32') { + return false + } + + try { + const result = spawnSync(`ls`, { + stdio: 'pipe', + }) + + return result.error !== undefined + } catch (err) { + return true + } +} /** * Run shell script in child process @@ -36,7 +53,8 @@ module.exports = function runScript(script, options, extraOptions) { if (script.indexOf('./') === 0 || script.indexOf('.\\') === 0 || script.indexOf('../') === 0 || script.indexOf('..\\') === 0) { const splits = script.split(' '); - splits[0] = path.join(options.cwd, splits[0]); + // in bash C:\Windows\system32 -> C:\\Windows\\system32 + splits[0] = path.join(isCmd() ? options.cwd : path.normalize(options.cwd), splits[0]); script = splits.join(' '); } } diff --git a/package.json b/package.json index ed4effb..54c811f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "runscript", - "version": "1.5.3", + "version": "1.5.4", "description": "Run script easy!", "main": "index.js", "files": [ @@ -8,12 +8,10 @@ "index.d.ts" ], "scripts": { - "contributor": "git-contributor", "test": "npm run lint && egg-bin test", "test-cov": "egg-bin cov", "lint": "eslint index.js test --fix", - "ci": "npm run lint && npm run test-cov", - "autod": "autod -w --prefix '^'" + "ci": "npm run lint && npm run test-cov" }, "dependencies": { "debug": "^2.6.8", @@ -23,10 +21,8 @@ "@types/node": "^12.0.8", "autod": "^3.1.0", "egg-bin": "^1.11.1", - "egg-ci": "^1.8.0", "eslint": "^4.19.1", "eslint-config-egg": "^6.0.0", - "git-contributor": "^1.0.10", "typescript": "^3.9.3" }, "homepage": "https://github.com/node-modules/runscript", @@ -46,11 +42,6 @@ "engines": { "node": ">=4.2.3" }, - "ci": { - "version": "8, 10, 12, 14, 16", - "type": "github", - "npminstall": false - }, - "author": "fengmk2 (https://fengmk2.com)", + "author": "fengmk2 (https://github.com/fengmk2)", "license": "MIT" }