Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
fix: run tests on windows (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Nov 24, 2020
1 parent ad715e5 commit 717c1a7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Node CI

on: [push]
on:
- push
- pull_request

jobs:
test:
Expand All @@ -9,7 +11,7 @@ jobs:
strategy:
matrix:
node_version: [10, 12, 14, 15]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node_version }}
Expand Down
16 changes: 16 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ if (args.help || args._.length === 0) {
process.exit(1)
}

// windows leaves leading/trailing quotes on strings needed on unix to
// stop shells from doing path expansion, so strip them if present
args._ = args._.map(stripQuotes)

function extensions (arg) {
if (!arg) return undefined
const extensions = {}
Expand All @@ -73,6 +77,18 @@ function extensions (arg) {
return extensions
}

function stripQuotes (string) {
if (string.startsWith("'") || string.startsWith('"')) {
string = string.slice(1)
}

if (string.endsWith("'") || string.endsWith('"')) {
string = string.slice(0, -1)
}

return string
}

check({
path: args._.shift(),
entries: args._,
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const promisedResolveModule = (file, options) => new Promise((resolve, reject) =
async function resolveGlobbedPath (entries, cwd) {
if (typeof entries === 'string') entries = [entries]

// replace backslashes for forward slashes for windows
entries = entries.map(entry => entry.replace(/\\/g, '/'))

debug('globby resolving', entries)

const resolvedEntries = await globby(entries, {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"lint": "standard",
"test-cli:custom-detective": "node cli.js test/ -e js:detective-cjs",
"test-cli:glob": "node cli.js 'test/**/*.js' --no-default-entries",
"test-cli:multi-glob": "node cli.js test/foo.js 'test/*.js' \"test/donkey/*.js\" --no-default-entries",
"test-cli:main-as-file": "node cli.js test/index.js",
"test-cli:simple": "node cli.js test/",
"test-cli": "run-p test-cli:*",
Expand Down

0 comments on commit 717c1a7

Please sign in to comment.