🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@publint/pack

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@publint/pack - npm Package Compare versions

Comparing version
0.1.4
to
0.1.5
+6
-3
package.json
{
"name": "@publint/pack",
"version": "0.1.4",
"version": "0.1.5",
"description": "Utilities for packing and unpacking npm packages",

@@ -34,5 +34,8 @@ "type": "module",

],
"dependencies": {
"tinyexec": "^1.2.4"
},
"devDependencies": {
"fs-fixture": "^2.11.0",
"vitest": "^4.0.18"
"fs-fixture": "^2.14.0",
"vitest": "^4.1.9"
},

@@ -39,0 +42,0 @@ "scripts": {

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

import cp from 'node:child_process'
import fs from 'node:fs/promises'
import util from 'node:util'
import { getTempPackDir } from './utils.js'
import { exec } from 'tinyexec'
import { getTempPackDir, resolvePackageManagerCommand } from './utils.js'

@@ -13,3 +12,4 @@ /** @type {import('../index.d.ts').packAsJson} */

let command = `${packageManager} pack --json`
const command = resolvePackageManagerCommand(packageManager)
command.push('pack', '--json')

@@ -22,6 +22,6 @@ // Handle tarball output. Try `--dry-run` if possible to not output any tarball,

if (supportsDryRun) {
command += ' --dry-run'
command.push('--dry-run')
} else {
packDestination = await getTempPackDir()
command += ` --pack-destination ${packDestination}`
command.push('--pack-destination', packDestination)
}

@@ -33,3 +33,3 @@

case 'pnpm':
command += ' --config.ignore-scripts=true'
command.push('--config.ignore-scripts=true')
break

@@ -40,3 +40,3 @@ case 'yarn':

default:
command += ' --ignore-scripts'
command.push('--ignore-scripts')
break

@@ -46,3 +46,3 @@ }

let { stdout } = await util.promisify(cp.exec)(command, { cwd: dir })
let { stdout } = await exec(command[0], command.slice(1), { nodeOptions: { cwd: dir } })

@@ -49,0 +49,0 @@ try {

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

import cp from 'node:child_process'
import fs from 'node:fs/promises'
import path from 'node:path'
import util from 'node:util'
import { exec } from 'tinyexec'
import { resolvePackageManagerCommand } from './utils.js'

@@ -10,6 +10,4 @@ /** @type {import('../index.d.ts').pack} */

let command = `${packageManager} pack`
if (packageManager === 'bun') {
command = command.replace('bun', 'bun pm')
}
const command = resolvePackageManagerCommand(packageManager)
command.push('pack')

@@ -21,9 +19,9 @@ // Handle tarball output

case 'yarn':
command += ` --out \"${path.join(packDestination, 'package.tgz')}\"`
command.push('--out', path.join(packDestination, 'package.tgz'))
break
case 'bun':
command += ` --destination \"${packDestination}\"`
command.push('--destination', packDestination)
break
default:
command += ` --pack-destination \"${packDestination}\"`
command.push('--pack-destination', packDestination)
break

@@ -37,3 +35,3 @@ }

case 'pnpm':
command += ' --config.ignore-scripts=true'
command.push('--config.ignore-scripts=true')
break

@@ -44,3 +42,3 @@ case 'yarn':

default:
command += ' --ignore-scripts'
command.push('--ignore-scripts')
break

@@ -50,3 +48,3 @@ }

const output = await util.promisify(cp.exec)(command, { cwd: dir })
const output = await exec(command[0], command.slice(1), { nodeOptions: { cwd: dir } })

@@ -53,0 +51,0 @@ // Get first file that ends with `.tgz` in the pack destination.

@@ -5,2 +5,18 @@ import fs from 'node:fs/promises'

/**
* @param {string} packageManager
* @returns {string[]}
*/
export function resolvePackageManagerCommand(packageManager) {
if (!['npm', 'yarn', 'pnpm', 'bun'].includes(packageManager)) {
throw new Error(`Unsupported package manager: ${packageManager}`)
}
// NOTE: Maybe consider using tinyexec if this isn't robust
const command = [packageManager]
if (packageManager === 'bun') {
command.push('pm')
}
return command
}
export async function getTempPackDir() {

@@ -7,0 +23,0 @@ const tempDir = os.tmpdir() + path.sep