Skip to content

Commit

Permalink
Use more abortSignal constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Dec 16, 2024
1 parent 2cd359a commit 7ce855e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 38 deletions.
10 changes: 1 addition & 9 deletions scripts/make-npm-override.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const util = require('node:util')
const { ReturnTypeEnums, default: didYouMean } = require('didyoumean2')
const { open } = require('out-url')
const semver = require('semver')
const { onExit } = require('signal-exit')
const { glob: tinyGlob } = require('tinyglobby')

const constants = require('@socketregistry/scripts/constants')
Expand All @@ -21,6 +20,7 @@ const {
TEMPLATE_ES_SHIM_CONSTRUCTOR,
TEMPLATE_ES_SHIM_PROTOTYPE_METHOD,
TEMPLATE_ES_SHIM_STATIC_METHOD,
abortSignal,
npmPackagesPath,
parseArgsConfig,
rootPath,
Expand Down Expand Up @@ -65,14 +65,6 @@ const {
const { indentString } = require('@socketsecurity/registry/lib/strings')
const { pluralize } = require('@socketsecurity/registry/lib/words')

const abortController = new AbortController()
const { signal: abortSignal } = abortController

// Detect ^C, i.e. Ctrl + C.
onExit(() => {
abortController.abort()
})

const { positionals: cliPositionals, values: cliArgs } =
util.parseArgs(parseArgsConfig)

Expand Down
10 changes: 1 addition & 9 deletions scripts/release-npm-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const path = require('node:path')

const semver = require('semver')
const { onExit } = require('signal-exit')
const ssri = require('ssri')

const constants = require('@socketregistry/scripts/constants')
Expand All @@ -12,6 +11,7 @@ const {
OVERRIDES,
PACKAGE_JSON,
PACKAGE_SCOPE,
abortSignal,
npmPackagesPath,
registryPkgPath,
relNpmPackagesPath,
Expand All @@ -27,14 +27,6 @@ const {
} = require('@socketsecurity/registry/lib/packages')
const { pEach } = require('@socketsecurity/registry/lib/promises')

const abortController = new AbortController()
const { signal: abortSignal } = abortController

// Detect ^C, i.e. Ctrl + C.
onExit(() => {
abortController.abort()
})

function packageData(data) {
const { printName = data.name, tag = LATEST } = data
return Object.assign(data, { printName, tag })
Expand Down
12 changes: 1 addition & 11 deletions scripts/update-package-json.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
'use strict'

const { onExit } = require('signal-exit')

const constants = require('@socketregistry/scripts/constants')
const { rootPackageJsonPath, rootPath } = constants
const { abortSignal, rootPackageJsonPath, rootPath } = constants
const { runScript } = require('@socketsecurity/registry/lib/npm')
const { readPackageJson } = require('@socketsecurity/registry/lib/packages')

const abortController = new AbortController()
const { signal: abortSignal } = abortController

// Detect ^C, i.e. Ctrl + C.
onExit(() => {
abortController.abort()
})

void (async () => {
const rootEditablePkgJson = await readPackageJson(rootPackageJsonPath, {
editable: true
Expand Down
10 changes: 1 addition & 9 deletions test/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { describe, it } from 'node:test'
import util from 'node:util'

import semver from 'semver'
import { onExit } from 'signal-exit'

import constants from '@socketregistry/scripts/constants'
const {
Expand All @@ -14,6 +13,7 @@ const {
PACKAGE_JSON,
README_GLOB_RECURSIVE,
WIN32,
abortSignal,
parseArgsConfig,
skipTestsByEcosystem,
testNpmNodeWorkspacesPath,
Expand All @@ -29,14 +29,6 @@ import { runScript } from '@socketsecurity/registry/lib/npm'
import { resolveOriginalPackageName } from '@socketsecurity/registry/lib/packages'
import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'

const abortController = new AbortController()
const { signal: abortSignal } = abortController

// Detect ^C, i.e. Ctrl + C.
onExit(() => {
abortController.abort()
})

// Pass args as tap --test-arg:
// npm run test:unit ./test/npm.test.ts -- --test-arg="--force"
const { values: cliArgs } = util.parseArgs(parseArgsConfig)
Expand Down

0 comments on commit 7ce855e

Please sign in to comment.