New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nano-staged

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano-staged - npm Package Compare versions

Comparing version

to
0.3.0

15

bin/index.js
#!/usr/bin/env node
import run from '../run/index.js'
import runner from '../run/index.js'

@@ -8,6 +8,15 @@ // Do not terminate main process on SIGINT

let options = {}
function run() {
let options = {}
let arg = process.argv[2]
run(options).catch(() => {
if (arg === '-c' || arg === '--config') {
options.configPath = process.argv[3]
}
return runner(options)
}
run().catch(() => {
process.exitCode = 1
})

19

config/index.js

@@ -1,2 +0,2 @@

import syncFs, { promises as fs } from 'fs'
import fs from 'fs'
import { resolve } from 'path'

@@ -8,3 +8,9 @@

export async function loadConfig(cwd = process.cwd()) {
export function readConfig(filepath) {
if (fs.existsSync(filepath) && fs.lstatSync(filepath).isFile()) {
return JSON.parse(fs.readFileSync(filepath, 'utf-8'))
}
}
export function loadConfig(cwd = process.cwd()) {
try {

@@ -20,8 +26,7 @@ let config

if (!config && syncFs.existsSync(path)) {
if (place === 'package.json') {
let pkg = JSON.parse(await fs.readFile(path, 'utf8'))
config = pkg[CONFIG_NAME]
if (!config && fs.existsSync(path)) {
if (place === NODE_PACKAGE_JSON) {
config = readConfig(path)[CONFIG_NAME]
} else {
config = JSON.parse(await fs.readFile(path, 'utf8'))
config = readConfig(path)
}

@@ -28,0 +33,0 @@

{
"name": "nano-staged",
"version": "0.2.1",
"version": "0.3.0",
"description": "Tool to run commands only on git staged files",

@@ -5,0 +5,0 @@ "author": "Usman Yunusov <usman.iunusov@gmail.com>",

@@ -6,5 +6,5 @@ # Nano Staged

- 📦 **Small**: 200x+ lighter than **lint-staged**.
- 🥇 **Single dependency** (Picocolors).
- 🥇 **Single dependency** ([`picocolors`](https://github.com/alexeyraspopov/picocolors)).
## Docs
Read **[full docs](https://github.com/usmanyunusov/nano-staged#readme)** on GitHub.

@@ -0,4 +1,5 @@

import { resolve } from 'path'
import pico from 'picocolors'
import { loadConfig, validConfig } from '../config/index.js'
import { loadConfig, readConfig, validConfig } from '../config/index.js'
import { createReporter } from '../create-reporter/index.js'

@@ -10,3 +11,7 @@ import { prepareFiles } from '../prepare-files/index.js'

export default async function run({ cwd = process.cwd(), stream = process.stderr } = {}) {
export default async function run({
configPath,
cwd = process.cwd(),
stream = process.stderr,
} = {}) {
let { log, info } = createReporter({ stream })

@@ -25,5 +30,10 @@

let config = await loadConfig(cwd)
let config = configPath ? readConfig(resolve(configPath)) : loadConfig(cwd)
if (!config) {
info(`Create Nano Staged config in package.json`)
if (configPath) {
info(`Nano Staged config file ${pico.yellow(configPath)} is not found`)
} else {
info(`Create Nano Staged config in package.json`)
}
return

@@ -30,0 +40,0 @@ }