mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2025-04-29 11:20:42 -04:00
add logs
This commit is contained in:
parent
935fc586de
commit
85dc1a16ee
2 changed files with 6 additions and 5 deletions
|
@ -3,17 +3,17 @@ const { join } = require('path');
|
||||||
|
|
||||||
const validateDir = (dir) => {
|
const validateDir = (dir) => {
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
console.log('[SSH] dir is not defined');
|
console.log('[DIR] dir is not defined');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (existsSync(dir)) {
|
if (existsSync(dir)) {
|
||||||
console.log(`[SSH] ${dir} dir exist`);
|
console.log(`[DIR] ${dir} dir exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[SSH] Creating ${dir} dir in workspace root`);
|
console.log(`[DIR] Creating ${dir} dir in workspace root`);
|
||||||
mkdirSync(dir);
|
mkdirSync(dir);
|
||||||
console.log('✅ [SSH] dir created.');
|
console.log('✅ [DIR] dir created.');
|
||||||
};
|
};
|
||||||
|
|
||||||
const writeToFile = ({ dir, filename, content, isRequired }) => {
|
const writeToFile = ({ dir, filename, content, isRequired }) => {
|
||||||
|
@ -29,6 +29,7 @@ const writeToFile = ({ dir, filename, content, isRequired }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log(`[FILE] writing ${filePath} file ...`, content.length);
|
||||||
writeFileSync(filePath, content, {
|
writeFileSync(filePath, content, {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
mode: 0o600
|
mode: 0o600
|
||||||
|
|
|
@ -8,7 +8,7 @@ const addSshKey = (content, filename) => {
|
||||||
const filePath = join(dir, filename);
|
const filePath = join(dir, filename);
|
||||||
|
|
||||||
writeToFile({ dir, filename: 'known_hosts', content: '' });
|
writeToFile({ dir, filename: 'known_hosts', content: '' });
|
||||||
console.log('✅ [SSH] known_hosts file ensured', dir, filename, content);
|
console.log('✅ [SSH] known_hosts file ensured', dir, filename, content.length);
|
||||||
writeToFile({ dir, filename, content, isRequired: true });
|
writeToFile({ dir, filename, content, isRequired: true });
|
||||||
console.log('✅ [SSH] key added to `.ssh` dir ', dir);
|
console.log('✅ [SSH] key added to `.ssh` dir ', dir);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue