nano-staged
Advanced tools
Comparing version 0.4.1 to 0.4.2
#!/usr/bin/env node | ||
import runner from './run.js' | ||
import { getForceColorLevel } from './utils.js' | ||
let FORCE_COLOR_LEVEL = getForceColorLevel() | ||
if (FORCE_COLOR_LEVEL) { | ||
process.env.FORCE_COLOR = FORCE_COLOR_LEVEL.toString() | ||
} | ||
// Do not terminate main process on SIGINT | ||
@@ -19,5 +25,4 @@ process.on('SIGINT', () => {}) | ||
run().catch((err) => { | ||
console.log(err) | ||
run().catch(() => { | ||
process.exitCode = 1 | ||
}) |
@@ -55,3 +55,2 @@ import { join, normalize } from 'path' | ||
/* c8 ignore next 3 */ | ||
if (threeWay) { | ||
@@ -58,0 +57,0 @@ args.push('--3way') |
@@ -83,4 +83,2 @@ import { resolve } from 'path' | ||
cwd: repoPath, | ||
preferLocal: true, | ||
env: { ...process.env, FORCE_COLOR: '1' }, | ||
}) | ||
@@ -87,0 +85,0 @@ |
@@ -63,3 +63,2 @@ import { resolve } from 'path' | ||
} else { | ||
/* c8 ignore next 2 */ | ||
log('\n' + pico.red(err.stack || err.message || err)) | ||
@@ -66,0 +65,0 @@ } |
import { fileURLToPath } from 'url' | ||
import { readFileSync } from 'fs' | ||
import pico from 'picocolors' | ||
import process from 'process' | ||
import { join } from 'path' | ||
import tty from 'tty' | ||
import os from 'os' | ||
@@ -36,1 +39,29 @@ const REG_STR = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi | ||
} | ||
export function getForceColorLevel() { | ||
if (process.env.FORCE_COLOR) { | ||
return Math.min(Number.parseInt(process.env.FORCE_COLOR, 10), 3) | ||
} else if (process.env.FORCE_NO_COLOR) { | ||
return 0 | ||
} else if (!tty.isatty(1)) { | ||
return 0 | ||
} else if (process.env.TERM === 'dumb') { | ||
return 0 | ||
} else if (process.platform === 'win32') { | ||
const osRelease = os.release().split('.') | ||
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) { | ||
return Number(osRelease[2]) >= 14_931 ? 3 : 2 | ||
} | ||
return 1 | ||
} else if (process.env.COLORTERM === 'truecolor') { | ||
return 3 | ||
} else if (/-256(color)?$/i.test(process.env.TERM)) { | ||
return 2 | ||
} else if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(process.env.TERM)) { | ||
return 1 | ||
} else if (process.env.COLORTERM) { | ||
return 1 | ||
} else { | ||
return 0 | ||
} | ||
} |
{ | ||
"name": "nano-staged", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Tool to run commands only on git staged files", | ||
@@ -5,0 +5,0 @@ "author": "Usman Yunusov <usman.iunusov@gmail.com>", |
@@ -5,3 +5,3 @@ # Nano Staged | ||
- 📦 **Small**: 200x+ lighter than **lint-staged**. | ||
- 📦 **Small**: 174x+ lighter than **lint-staged**. | ||
- 🥇 **Single dependency** ([`picocolors`](https://github.com/alexeyraspopov/picocolors)). | ||
@@ -8,0 +8,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33230
1091
24