修改mkdir

This commit is contained in:
moweilin 2024-01-17 23:55:31 +08:00
parent 1fca7cb1f4
commit 8a9ce2ac2b
3 changed files with 5 additions and 7 deletions

5
dist/index.js vendored
View File

@ -26587,20 +26587,19 @@ var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => { (() => {
const core = __nccwpck_require__(2186); const core = __nccwpck_require__(2186);
const { mkdir, writeFileSync, existsSync } = __nccwpck_require__(7147); const { writeFileSync, existsSync, mkdirSync } = __nccwpck_require__(7147);
const os = __nccwpck_require__(2037); const os = __nccwpck_require__(2037);
const path = __nccwpck_require__(1017); const path = __nccwpck_require__(1017);
try { try {
// `who-to-greet` input defined in action metadata file // `who-to-greet` input defined in action metadata file
const kubeconfig = core.getInput('kubeconfig'); const kubeconfig = core.getInput('kubeconfig');
core.info(`input:\n${kubeconfig}\n************\n`)
if(!kubeconfig){ if(!kubeconfig){
throw { throw {
message: "kubeconfig should not be empty" message: "kubeconfig should not be empty"
} }
} }
const parentDir = path.join(os.homedir(),".kube") const parentDir = path.join(os.homedir(),".kube")
mkdir(parentDir,{recursive:true}) mkdirSync(parentDir,{recursive:true})
const configFile = path.join(parentDir,"config") const configFile = path.join(parentDir,"config")
if(existsSync(configFile) && !core.getBooleanInput("force")){ if(existsSync(configFile) && !core.getBooleanInput("force")){
throw { throw {

View File

@ -1,6 +1,6 @@
{ {
"name": "action-kubernetes-login", "name": "action-kubernetes-login",
"version": "0.0.4", "version": "0.0.5",
"type": "commonjs", "type": "commonjs",
"scripts": { "scripts": {
"build": "ncc build src/index.js -o dist" "build": "ncc build src/index.js -o dist"

View File

@ -1,18 +1,17 @@
const core = require('@actions/core'); const core = require('@actions/core');
const { mkdir, writeFileSync, existsSync } = require('fs'); const { writeFileSync, existsSync, mkdirSync } = require('fs');
const os = require('os'); const os = require('os');
const path = require('path'); const path = require('path');
try { try {
// `who-to-greet` input defined in action metadata file // `who-to-greet` input defined in action metadata file
const kubeconfig = core.getInput('kubeconfig'); const kubeconfig = core.getInput('kubeconfig');
core.info(`input:\n${kubeconfig}\n************\n`)
if(!kubeconfig){ if(!kubeconfig){
throw { throw {
message: "kubeconfig should not be empty" message: "kubeconfig should not be empty"
} }
} }
const parentDir = path.join(os.homedir(),".kube") const parentDir = path.join(os.homedir(),".kube")
mkdir(parentDir,{recursive:true}) mkdirSync(parentDir,{recursive:true})
const configFile = path.join(parentDir,"config") const configFile = path.join(parentDir,"config")
if(existsSync(configFile) && !core.getBooleanInput("force")){ if(existsSync(configFile) && !core.getBooleanInput("force")){
throw { throw {