Skip to content

Commit

Permalink
fix(): default npm (#12)
Browse files Browse the repository at this point in the history
* fix(): default npm
  • Loading branch information
ShaMan123 committed Sep 30, 2022
1 parent acf29a4 commit 3965627
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ inputs:
default: ${{ github.token }}

package:
description: The name of the published package
default: ${{ github.event.repository.name }}
description: |
The name of the published package
By default infers:
- npm package from `package.json`
- github repo from context
type: string

registry:
Expand Down
9 changes: 7 additions & 2 deletions dist/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -89788,6 +89788,9 @@ function getOctokit(token, options, ...additionalPlugins) {
github.getOctokit = getOctokit;

function listNPMTags(packageName) {
if (!packageName) {
packageName = JSON.parse(require$$0$1.readFileSync('package.json')).name;
}
coreExports.info(`Fetching npm versions for ${packageName}`);
return JSON.parse(
cp__default["default"].execSync(`npm view ${packageName} versions --json`).toString(),
Expand All @@ -89797,9 +89800,12 @@ async function listGithubReleases(repoName) {
let owner, repo;
if (repoName.indexOf('/') > -1) {
[owner, repo] = repoName.split('/');
} else {
} else if (repoName) {
owner = github.context.repo.owner;
repo = repoName;
} else {
owner = github.context.repo.owner;
repo = github.context.repo.repo;
}
coreExports.info(`Fetching github releases for ${owner}/${repo}`);
let page = 1;
Expand Down Expand Up @@ -89842,7 +89848,6 @@ async function run() {
try {
const packageName = coreExports.getInput('package', {
trimWhitespace: true,
required: true,
});
const registry = coreExports.getInput('registry', {
trimWhitespace: true,
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ async function run() {
try {
const packageName = getInput('package', {
trimWhitespace: true,
required: true,
});
const registry = getInput('registry', {
trimWhitespace: true,
Expand Down
9 changes: 8 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import github from '@actions/github';
import { info } from '@actions/core';
import cp from 'node:child_process';
import { readFileSync } from 'node:fs';

function listNPMTags(packageName) {
if (!packageName) {
packageName = JSON.parse(readFileSync('package.json')).name;
}
info(`Fetching npm versions for ${packageName}`);
return JSON.parse(
cp.execSync(`npm view ${packageName} versions --json`).toString(),
Expand All @@ -12,9 +16,12 @@ async function listGithubReleases(repoName) {
let owner, repo;
if (repoName.indexOf('/') > -1) {
[owner, repo] = repoName.split('/');
} else {
} else if (repoName) {
owner = github.context.repo.owner;
repo = repoName;
} else {
owner = github.context.repo.owner;
repo = github.context.repo.repo;
}
info(`Fetching github releases for ${owner}/${repo}`);
let page = 1;
Expand Down

0 comments on commit 3965627

Please sign in to comment.