12345678910111213141516171819 |
- const fs = require('fs')
- var ogWrite = process.stdout.write;
- function init (_projectName, TAG) {
- const isExists = fs.existsSync(`${process.cwd()}/logs/${_projectName}`)
- if (!isExists) {
- fs.mkdirSync(`${process.cwd()}/logs/${_projectName}`)
- }
- if (!fs.existsSync(`${process.cwd()}/logs/${_projectName}/${TAG}`)) {
- fs.mkdirSync(`${process.cwd()}/logs/${_projectName}/${TAG}`)
- }
- process.stdout.write = function( chunk ){
- fs.appendFile( `./logs/${_projectName}/${TAG}/log.txt`, chunk, () => {} );
- // this will write the output to the console
- ogWrite.apply( this, arguments );
- }
- }
- module.exports = init
|