mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2026-03-01 08:01:01 +08:00
fix config.js
This commit is contained in:
parent
e588524852
commit
11d612552f
@ -1,5 +1,4 @@
|
|||||||
const { readFileSync, existsSync } = require('fs');
|
const { readFileSync, existsSync } = require('fs');
|
||||||
const { handleError } = require('./helpers');
|
|
||||||
|
|
||||||
const githubWorkspace = process.env.GITHUB_WORKSPACE;
|
const githubWorkspace = process.env.GITHUB_WORKSPACE;
|
||||||
const inputConfigKey = 'CONFIG_PATH';
|
const inputConfigKey = 'CONFIG_PATH';
|
||||||
@ -8,7 +7,7 @@ const inputSshKeyPath = 'SSH_PRIVATE_KEY_PATH';
|
|||||||
const readConfig = (configPath) => {
|
const readConfig = (configPath) => {
|
||||||
if (existsSync(configPath)) {
|
if (existsSync(configPath)) {
|
||||||
const message = `⚠️ [FILE] ${configPath} Required file exist.`;
|
const message = `⚠️ [FILE] ${configPath} Required file exist.`;
|
||||||
handleError(message, true);
|
console.warn(message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -17,7 +16,7 @@ const readConfig = (configPath) => {
|
|||||||
return JSON.parse(fileContents);
|
return JSON.parse(fileContents);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = `⚠️[FILE] reading file error. configPath: ${configPath}, message: ${error.message}`;
|
const message = `⚠️[FILE] reading file error. configPath: ${configPath}, message: ${error.message}`;
|
||||||
handleError(message, true);
|
console.warn(message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -25,7 +24,7 @@ const readConfig = (configPath) => {
|
|||||||
const readSshKey = (SshKeyPath) => {
|
const readSshKey = (SshKeyPath) => {
|
||||||
if (existsSync(SshKeyPath)) {
|
if (existsSync(SshKeyPath)) {
|
||||||
const message = `⚠️ [FILE] ${SshKeyPath} Required file exist.`;
|
const message = `⚠️ [FILE] ${SshKeyPath} Required file exist.`;
|
||||||
handleError(message, true);
|
console.warn(message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -33,7 +32,7 @@ const readSshKey = (SshKeyPath) => {
|
|||||||
return readFileSync(SshKeyPath, 'utf8');
|
return readFileSync(SshKeyPath, 'utf8');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = `⚠️[FILE] reading file error. configPath: ${SshKeyPath}, message: ${error.message}`;
|
const message = `⚠️[FILE] reading file error. configPath: ${SshKeyPath}, message: ${error.message}`;
|
||||||
handleError(message, true);
|
console.warn(message);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user