diff --git a/src/index.js b/src/index.js index 675305a..9493d9a 100644 --- a/src/index.js +++ b/src/index.js @@ -11,31 +11,35 @@ const envPath = path.join(process.cwd(), fileName) const bufferEncoding = 'utf8' -if (fs.existsSync(envPath)) { - fs.readFile(envPath, bufferEncoding, (errorRead, fileData) => { - if (errorRead) { - console.log(errorRead) +function run() { + if (fs.existsSync(envPath)) { + fs.readFile(envPath, bufferEncoding, (errorRead, fileData) => { + if (errorRead) { + console.log({ errorRead }) - return - } + return + } - const result = fileData.replace(regex, '') + const result = fileData.replace(regex, '') - fs.writeFile( - path.join(process.cwd(), '.env.example'), - result, - bufferEncoding, - errorWrite => { - if (errorWrite) { - console.log(errorWrite) + fs.writeFile( + path.join(process.cwd(), '.env.example'), + result, + bufferEncoding, + errorWrite => { + if (errorWrite) { + console.log({ errorWrite }) - return - } + return + } - console.log('\nSuccessfully created .env.example') - } - ) - }) -} else { - console.log(`\nNo ${fileName} file found`) + console.log('\nSuccessfully created .env.example') + } + ) + }) + } else { + console.log(`\nNo ${fileName} file found`) + } } + +run()