Skip to content

Commit

Permalink
chore: run type-checks on bin files
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed Oct 23, 2023
1 parent 19a8358 commit baa0dfc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions bin/docker.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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());
});

Expand Down
3 changes: 2 additions & 1 deletion bin/json-schema-store.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env node
// @ts-check
/* eslint-disable import/no-extraneous-dependencies */
import fs from 'node:fs/promises';

Expand All @@ -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 => {
Expand Down
3 changes: 3 additions & 0 deletions bin/set-action-image.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env node
// @ts-check
import fs from 'node:fs/promises';

// eslint-disable-next-line import/no-extraneous-dependencies
Expand All @@ -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' });
Expand Down
9 changes: 7 additions & 2 deletions bin/set-major-version-tag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env node
// @ts-check
import { execFile as unpromisifiedExecFile } from 'node:child_process';
import util from 'node:util';

Expand All @@ -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());
});
Expand All @@ -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');
Expand Down
1 change: 1 addition & 0 deletions bin/set-version-output.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env node
// @ts-check
import * as core from '@actions/core';

// eslint-disable-next-line import/extensions
Expand Down

0 comments on commit baa0dfc

Please sign in to comment.