Skip to content

Commit b4f48ed

Browse files
committed
assume the first argument is a file if it contains a JS extension
1 parent 422a149 commit b4f48ed

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
const {createWriteStream, mkdir} = require('fs');
5-
const {dirname, join, resolve: resolvePath} = require('path');
5+
const {dirname, extname, join, resolve: resolvePath} = require('path');
66
const {promisify} = require('util');
77
const {spawn} = require('child_process');
88

@@ -58,9 +58,20 @@ const codecovBashPath = process.platform === 'win32' ? join(cwd, 'coverage', uui
5858
}
5959

6060
const prepareArgs = (async () => {
61-
try {
62-
await promisifiedWhich(command);
63-
} catch {
61+
const ext = extname(command).slice(1).toLowerCase();
62+
let isJavaScriptFile = false;
63+
64+
if (ext === 'cjs' || ext === 'js' || ext === 'mjs') {
65+
isJavaScriptFile = true;
66+
} else {
67+
try {
68+
await promisifiedWhich(command);
69+
} catch {
70+
isJavaScriptFile = true;
71+
}
72+
}
73+
74+
if (isJavaScriptFile) {
6475
let entryPath = resolvePath(cwd, command);
6576

6677
try {

0 commit comments

Comments
 (0)