Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logMessage(message, data) {
if (!message) return
render(message, data, (err, res) => {
if (err) {
console.error('\n Error when rendering template complete message: ' +
err.message.trim())
} else {
console.log('\n' +
res
.split(/\r?\n/g)
.map(line => ' ' + line)
.join('\n'))
}
})
}
function logMessage(message: string, data: Obj): void {
if (!message) return
render(message, data, (err: any, res: string) => {
if (err) {
console.error('\n Error when rendering template complete message: ' + err.message.trim())
} else {
console.log(
'\n' +
res
.split(/\r?\n/g)
.map(line => ' ' + line)
.join('\n')
)
}
})
}
(key, next) => {
const str = files[key].contents.toString()
if (!/{{([^{}]+)}}/g.test(str)) {
return next()
}
render(str, data, (err, res) => {
if (err) {
err.message = `[${key}] ${err.message}`
return next(err)
}
if (key === '.easy-mock.js' && !data.easymock) {
delete files[key]
delete data.easymock
} else {
files[key].contents = Buffer.from(res)
}
next()
})
},
done
(key: number | string, next: any) => {
const str = files[key].contents.toString()
if (!/{{([^{}]+)}}/g.test(str)) {
return next()
}
render(str, data, (err: any, res: any) => {
if (err) {
err.message = `[${key}] ${err.message}`
return next(err)
}
if (key === '.easy-mock.js' && !data.easymock) {
delete files[key]
delete data.easymock
} else {
files[key].contents = Buffer.from(res)
}
next()
})
},
done