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

borp

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

borp - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

fixtures/ts-cjs-post-compile/package.json

1

borp.js

@@ -36,2 +36,3 @@ #! /usr/bin/env node

'no-typescript': { type: 'boolean', short: 'T' },
'post-compile': { type: 'string', short: 'P' },
reporter: {

@@ -38,0 +39,0 @@ type: 'string',

@@ -32,2 +32,21 @@ import { run } from 'node:test'

let postCompileFn = async () => {}
if (config['post-compile']) {
postCompileFn = async (outDir) => {
const postCompileFile = join(outDir ?? '', config['post-compile']).replace(/\.ts$/, '.js')
const postCompileStart = Date.now()
const { stdout } = await execa('node', [postCompileFile], { cwd: dirname(tsconfigPath) })
pushable.push({
type: 'test:diagnostic',
data: {
nesting: 0,
message: `Post compile hook complete (${Date.now() - postCompileStart}ms)`,
details: stdout,
typescriptCliArgs
}
})
}
}
if (tsconfigPath && config.typescript !== false) {

@@ -38,2 +57,7 @@ const tsconfig = JSON.parse(await readFile(tsconfigPath))

tscPath = join(typescriptPathCWD, '..', '..', 'bin', 'tsc')
const outDir = tsconfig.compilerOptions.outDir
if (outDir) {
prefix = join(dirname(tsconfigPath), outDir)
}
if (tscPath) {

@@ -59,8 +83,6 @@ // This will throw if we cannot find the `tsc` binary

})
await postCompileFn(outDir)
}
}
const outDir = tsconfig.compilerOptions.outDir
if (outDir) {
prefix = join(dirname(tsconfigPath), outDir)
}
}

@@ -96,6 +118,11 @@

p = deferred()
let outDir = ''
if (config['post-compile'] && tsconfigPath) {
const tsconfig = JSON.parse(await readFile(tsconfigPath))
outDir = tsconfig.compilerOptions.outDir
}
let start = Date.now()
tscChild = execa('node', [tscPath, ...typescriptCliArgs], { cwd })
tscChild.stdout.setEncoding('utf8')
tscChild.stdout.on('data', (data) => {
tscChild.stdout.on('data', async (data) => {
if (data.includes('File change detected')) {

@@ -113,2 +140,4 @@ start = Date.now()

await postCompileFn(outDir)
p.resolve()

@@ -115,0 +144,0 @@ }

2

package.json
{
"name": "borp",
"version": "0.10.0",
"version": "0.11.0",
"type": "module",

@@ -5,0 +5,0 @@ "description": "node:test wrapper with TypeScript support",

@@ -88,2 +88,3 @@ # borp

* `--concurrency` or `-c`, to set the number of concurrent tests. Defaults to the number of available CPUs minus one.
* `--coverage` or `-C`, enables code coverage

@@ -99,2 +100,3 @@ * `--only` or `-o`, only run `node:test` with the `only` option set

* `--no-typescript` or `-T`, disable automatic TypeScript compilation if `tsconfig.json` is found.
* `--post-compile` or `-P`, the path to a file that will be executed after each typescript compilation.

@@ -101,0 +103,0 @@ ## Reporters

@@ -91,1 +91,24 @@ import { test } from 'node:test'

})
test('Post compile script should be executed when --post-compile is sent with esm', async () => {
const cwd = join(import.meta.url, '..', 'fixtures', 'ts-esm-post-compile')
const { stdout } = await execa('node', [
borp,
'--post-compile=postCompile.ts'
], {
cwd
})
strictEqual(stdout.indexOf('Post compile hook complete') >= 0, true, 'Post compile message should be found in stdout')
})
test('Post compile script should be executed when --post-compile is sent with cjs', async () => {
const { stdout } = await execa('node', [
borp,
'--post-compile=postCompile.ts'
], {
cwd: join(import.meta.url, '..', 'fixtures', 'ts-cjs-post-compile')
})
strictEqual(stdout.indexOf('Post compile hook complete') >= 0, true, 'Post compile message should be found in stdout')
})

@@ -112,1 +112,62 @@ import { test } from 'node:test'

})
test('watch with post compile hook should call the hook the right number of times', async (t) => {
const { strictEqual, completed, ok } = tspl(t, { plan: 2 })
const dir = path.resolve(await mkdtemp('.test-watch-with-post-compile-hook'))
await cp(join(import.meta.url, '..', 'fixtures', 'ts-esm-post-compile'), dir, {
recursive: true
})
const controller = new AbortController()
t.after(async () => {
controller.abort()
try {
await rm(dir, { recursive: true, retryDelay: 100, maxRetries: 10 })
} catch {}
})
const config = {
'post-compile': 'postCompile.ts',
files: [],
cwd: dir,
signal: controller.signal,
watch: true
}
const stream = await runWithTypeScript(config)
const fn = (test) => {
if (test.type === 'test:fail') {
strictEqual(test.data.name, 'add')
stream.removeListener('data', fn)
}
}
stream.on('data', fn)
let postCompileEventCount = 0
const diagnosticListenerFn = (test) => {
if (test.type === 'test:diagnostic' && test.data.message.includes('Post compile hook complete')) {
if (++postCompileEventCount === 2) {
ok(true, 'Post compile hook ran twice')
stream.removeListener('data', diagnosticListenerFn)
}
}
}
stream.on('data', diagnosticListenerFn)
const toWrite = `
import { test } from 'node:test'
import { add } from '../src/add.js'
import { strictEqual } from 'node:assert'
test('add', () => {
strictEqual(add(1, 2), 4)
})
`
const file = path.join(dir, 'test', 'add.test.ts')
await writeFile(file, toWrite)
await completed
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc