Skip to content

Commit

Permalink
switch publish-packages.mjs to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed May 5, 2024
1 parent 2362453 commit 040c1d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"install": "node-pre-gyp install --fallback-to-build -j max",
"preversion": "npm run lint && npm run test && npm run doc",
"version": "git add package.json doc",
"postversion": "git push && git push --tags && node ./scripts/publish-packages.js",
"postversion": "git push && git push --tags && node ./scripts/publish-packages.mjs",
"postpublish": "gh workflow run test-package.yml -F version=$npm_package_version",
"doc": "documentation build -f md lib/index.d.ts > doc/API.md",
"gcov": "mkdir -p coverage && cd coverage && gcov -o ../build/Debug/obj.target/everything-json/src ../src/*",
Expand Down
30 changes: 17 additions & 13 deletions scripts/publish-packages.js → scripts/publish-packages.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
// This script tries to find a publishing workflow with a dispatch trigger
// in the Github Actions of the current project

const exec = require('util').promisify(require('child_process').exec);
const path = require('path');
const { Octokit } = require('@octokit/core');

const octokit = new Octokit({ auth: process.env.NODE_PRE_GYP_GITHUB_TOKEN });
const package_json = require(path.resolve(__dirname, '..', 'package.json'));
const pkg = {
repo: package_json.binary.hosting.repo.split('/')[1],
owner: package_json.binary.hosting.repo.split('/')[0]
};
const version = package_json.version;
let workflowPublishId;
const workflowPublishMatch = /publish/;
import { exec as _exec } from 'node:child_process';
import { promisify } from 'node:util';
import * as path from 'node:path';
import { promises as fs } from 'node:fs';
import { Octokit } from '@octokit/core';
import { fileURLToPath } from 'node:url';
const exec = promisify(_exec);

(async () => {
const octokit = new Octokit({ auth: process.env.NODE_PRE_GYP_GITHUB_TOKEN });
const package_json = JSON.parse(await fs.readFile(path.resolve(fileURLToPath(import.meta.url), '..', '..', 'package.json'), 'utf-8'));
const pkg = {
repo: package_json.binary.hosting.repo.split('/')[1],
owner: package_json.binary.hosting.repo.split('/')[0]
};
const version = package_json.version;
let workflowPublishId;
const workflowPublishMatch = /publish/;

const branch = (await exec('git branch --show-current')).stdout.trim();

process.stdout.write(`trying to find the publish workflow for ${pkg.owner}:${pkg.repo}...`);
Expand Down

0 comments on commit 040c1d6

Please sign in to comment.