mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2026-03-04 08:31:07 +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) => {
|
const readConfig = (configPath) => {
|
||||||
if (existsSync(configPath)) {
|
if (existsSync(configPath)) {
|
||||||
const message = `⚠️ [FILE] ${configPath} Required file exist.`;
|
const message = `⚠️ [FILE] ${configPath} Required file exist.`;
|
||||||
console.warn(message);
|
throw new Error(message);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
console.log(`[FILE] reading ${configPath} file ...`);
|
console.log(`[FILE] reading ${configPath} file ...`);
|
||||||
@ -16,24 +15,21 @@ 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}`;
|
||||||
console.warn(message);
|
throw new Error(message);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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.`;
|
||||||
console.warn(message);
|
throw new Error(message);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
console.log(`[FILE] reading ${SshKeyPath} file ...`);
|
console.log(`[FILE] reading ${SshKeyPath} file ...`);
|
||||||
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}`;
|
||||||
console.warn(message);
|
throw new Error(message);
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user