11import core from "@actions/core" ;
22import { mkdir , writeFile } from "node:fs/promises" ;
33import path from "node:path" ;
4+
5+ import { getInput , info , setFailed , setOutput , warning } from "@actions/core" ;
46import statsApi from "github-readme-stats/api/index.js" ;
57import repoApi from "github-readme-stats/api/pin.js" ;
68import topLangsApi from "github-readme-stats/api/top-langs.js" ;
@@ -32,14 +34,16 @@ const normalizeOptions = (options) => {
3234 * @returns {Record<string, string> } Parsed options.
3335 */
3436const parseOptions = ( value ) => {
35- if ( ! value ) return { } ;
37+ if ( ! value ) {
38+ return { } ;
39+ }
3640
3741 const trimmed = value . trim ( ) ;
3842 const options = { } ;
3943 if ( trimmed . startsWith ( "{" ) ) {
4044 try {
4145 Object . assign ( options , JSON . parse ( trimmed ) ) ;
42- } catch ( error ) {
46+ } catch {
4347 throw new Error ( "Invalid JSON in options." ) ;
4448 }
4549 } else {
@@ -77,7 +81,7 @@ const cardHandlers = {
7781const validateCardOptions = ( card , query , repoOwner ) => {
7882 if ( ! query . username && repoOwner ) {
7983 query . username = repoOwner ;
80- core . warning ( "username not provided; defaulting to repository owner." ) ;
84+ warning ( "username not provided; defaulting to repository owner." ) ;
8185 }
8286 switch ( card ) {
8387 case "stats" :
@@ -103,9 +107,9 @@ const validateCardOptions = (card, query, repoOwner) => {
103107} ;
104108
105109const run = async ( ) => {
106- const card = core . getInput ( "card" , { required : true } ) . toLowerCase ( ) ;
107- const optionsInput = core . getInput ( "options" ) || "" ;
108- const outputPathInput = core . getInput ( "path" ) ;
110+ const card = getInput ( "card" , { required : true } ) . toLowerCase ( ) ;
111+ const optionsInput = getInput ( "options" ) || "" ;
112+ const outputPathInput = getInput ( "path" ) ;
109113
110114 const handler = cardHandlers [ card ] ;
111115 if ( ! handler ) {
@@ -136,10 +140,10 @@ const run = async () => {
136140 }
137141
138142 await writeFile ( outputPath , svg , "utf8" ) ;
139- core . info ( `Wrote ${ outputPath } ` ) ;
140- core . setOutput ( "path" , outputPathValue ) ;
143+ info ( `Wrote ${ outputPath } ` ) ;
144+ setOutput ( "path" , outputPathValue ) ;
141145} ;
142146
143147run ( ) . catch ( ( error ) => {
144- core . setFailed ( error instanceof Error ? error . message : String ( error ) ) ;
148+ setFailed ( error instanceof Error ? error . message : String ( error ) ) ;
145149} ) ;
0 commit comments