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
c080837434
commit
110333f488
@ -7,8 +7,7 @@ const inputSshKeyPath = 'SSH_PRIVATE_KEY_PATH';
|
||||
const readConfig = (configPath) => {
|
||||
if (existsSync(configPath)) {
|
||||
const message = `⚠️ [FILE] ${configPath} Required file exist.`;
|
||||
console.warn(message);
|
||||
return null;
|
||||
throw new Error(message);
|
||||
}
|
||||
try {
|
||||
console.log(`[FILE] reading ${configPath} file ...`);
|
||||
@ -16,24 +15,21 @@ const readConfig = (configPath) => {
|
||||
return JSON.parse(fileContents);
|
||||
} catch (error) {
|
||||
const message = `⚠️[FILE] reading file error. configPath: ${configPath}, message: ${error.message}`;
|
||||
console.warn(message);
|
||||
return null;
|
||||
throw new Error(message);
|
||||
}
|
||||
};
|
||||
|
||||
const readSshKey = (SshKeyPath) => {
|
||||
if (existsSync(SshKeyPath)) {
|
||||
const message = `⚠️ [FILE] ${SshKeyPath} Required file exist.`;
|
||||
console.warn(message);
|
||||
return null;
|
||||
throw new Error(message);
|
||||
}
|
||||
try {
|
||||
console.log(`[FILE] reading ${SshKeyPath} file ...`);
|
||||
return readFileSync(SshKeyPath, 'utf8');
|
||||
} catch (error) {
|
||||
const message = `⚠️[FILE] reading file error. configPath: ${SshKeyPath}, message: ${error.message}`;
|
||||
console.warn(message);
|
||||
return '';
|
||||
throw new Error(message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user