Skip to content

Commit

Permalink
Merge pull request #5 from celsodias12/dev
Browse files Browse the repository at this point in the history
feat: add wrapper function
  • Loading branch information
celsodias12 authored Apr 20, 2022
2 parents 6a6b77d + 7907aa0 commit c56befe
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit c56befe

Please sign in to comment.