diff --git a/bin/docker.js b/bin/docker.js index 17f9630df..c18474800 100755 --- a/bin/docker.js +++ b/bin/docker.js @@ -1,4 +1,5 @@ #! /usr/bin/env node +// @ts-check /* eslint-disable no-console */ import { execFile as unpromisifiedExecFile } from 'node:child_process'; import util from 'node:util'; @@ -36,11 +37,11 @@ async function runDockerCmd(args) { const execCmd = execFile('docker', args); const child = execCmd.child; - child.stdout.on('data', chunk => { + child.stdout?.on('data', chunk => { console.log(chunk.toString()); }); - child.stderr.on('data', chunk => { + child.stderr?.on('data', chunk => { console.error(chunk.toString()); }); diff --git a/bin/json-schema-store.js b/bin/json-schema-store.js index d21c15039..679acdea8 100755 --- a/bin/json-schema-store.js +++ b/bin/json-schema-store.js @@ -1,4 +1,5 @@ #! /usr/bin/env node +// @ts-check /* eslint-disable import/no-extraneous-dependencies */ import fs from 'node:fs/promises'; @@ -22,7 +23,7 @@ const files = [ */ async function refreshSchemas() { const isUpdate = process.argv.includes('--update'); - const prettierConfig = await prettier.resolveConfig(); + const prettierConfig = await prettier.resolveConfig(process.cwd()); try { await Promise.all( files.map(async file => { diff --git a/bin/set-action-image.js b/bin/set-action-image.js index a2e6fae4f..b0410610f 100755 --- a/bin/set-action-image.js +++ b/bin/set-action-image.js @@ -1,4 +1,5 @@ #! /usr/bin/env node +// @ts-check import fs from 'node:fs/promises'; // eslint-disable-next-line import/no-extraneous-dependencies @@ -16,8 +17,10 @@ async function setActionImage() { // and writes changes back to action.yml file const actionFile = await fs.readFile('./action.yml', 'utf-8'); const actionObj = jsYaml.load(actionFile); + // @ts-expect-error it's annoying to type these YAML instances const imageURL = new URL(actionObj.runs.image); imageURL.pathname = imageURL.pathname.replace(/:.*/g, `:${pkg.version}`); + // @ts-expect-error it's annoying to type these YAML instances actionObj.runs.image = imageURL.toString(); const actionYaml = jsYaml.dump(actionObj, { lineWidth: -1 }); await fs.writeFile('./action.yml', actionYaml, { encoding: 'utf-8' }); diff --git a/bin/set-major-version-tag.js b/bin/set-major-version-tag.js index 0a4bef4d4..97b351f68 100755 --- a/bin/set-major-version-tag.js +++ b/bin/set-major-version-tag.js @@ -1,4 +1,5 @@ #! /usr/bin/env node +// @ts-check import { execFile as unpromisifiedExecFile } from 'node:child_process'; import util from 'node:util'; @@ -16,12 +17,12 @@ async function runGitCmd(args) { const execCmd = execFile('git', args); const child = execCmd.child; - child.stdout.on('data', chunk => { + child.stdout?.on('data', chunk => { // eslint-disable-next-line no-console console.log(chunk.toString()); }); - child.stderr.on('data', chunk => { + child.stderr?.on('data', chunk => { // eslint-disable-next-line no-console console.error(chunk.toString()); }); @@ -38,6 +39,10 @@ async function setMajorVersionTag() { try { const parsedVersion = parse(pkg.version); + if (!parsedVersion) { + throw new Error('Unable to extract semver data from the `package.json` version.'); + } + if (parsedVersion.prerelease.length) { // eslint-disable-next-line no-console console.warn('Pre-release version, not setting major version tag'); diff --git a/bin/set-version-output.js b/bin/set-version-output.js index 8cae398c9..11b9c1428 100755 --- a/bin/set-version-output.js +++ b/bin/set-version-output.js @@ -1,4 +1,5 @@ #! /usr/bin/env node +// @ts-check import * as core from '@actions/core'; // eslint-disable-next-line import/extensions