Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const cli = require('commander')
// Import our package data for versioning
const { version } = require('../package.json')
// Import out projectz utility
const { Projectz } = require('./index.js')
// Prepare our logging configuration
const LOG_LEVEL_INFO = 6
const LOG_LEVEL_DEBUG = 7
const EXIT_ERROR_CODE = 1
const level = process.argv.includes('-d') ? LOG_LEVEL_DEBUG : LOG_LEVEL_INFO
// Setup our logging
const logger = new Logger({ level })
const filter = new Filter()
const human = new Human()
// Pipe logger output to filter, then filter output to stdout
logger
.pipe(filter)
.pipe(human)
.pipe(process.stdout)
// Extract out version out of our package and apply it to commander
cli.version(version)
// Define usage information
cli.usage(' [options]')
// Add our cwd customisation
LogService.prototype.initialize = function () {
"use strict";
var logFilter, logHuman;
logHuman = human.createHuman();
//create the logger
this._logger = new Logger(this._settings.config);
if (this._settings.loggers.console.enabled) {
logFilter = filter.createFilter({level: (this._settings.loggers.console.debug ? 7 : 6)});
this._logger.pipe(logFilter).pipe(logHuman).pipe(process.stdout);
}
if (this._settings.loggers.file.enabled) {
if (!fs.existsSync(path.dirname(this._settings.loggers.file.filename))) {
fs.mkdirSync(path.dirname(this._settings.loggers.file.filename));
}
logFilter = filter.createFilter({level: (this._settings.loggers.file.debug ? 7 : 6)});
this._logger.pipe(logFilter).pipe(es.join('\n')).pipe(fs.createWriteStream(this._settings.loggers.file.filename, {flags: 'a'}));
}
};
if (err && docpad.getDebugging()) {
locale = docpad.getLocale();
return docpad.log('warn', locale.reportError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
}
});
this.trackRunnerInstance = new TaskGroup().run().on('complete', function(err) {
var locale, _ref2;
if (err && docpad.getDebugging()) {
locale = docpad.getLocale();
return docpad.log('warn', locale.trackError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
}
});
if ((loggers = instanceConfig.loggers)) {
delete instanceConfig.loggers;
} else {
logger = new (require('caterpillar').Logger)({
lineOffset: 2
});
loggerConsole = logger.pipe(new (require('caterpillar-filter').Filter)).pipe(new (require('caterpillar-human').Human));
loggers = {
logger: logger,
console: loggerConsole
};
}
safefs.unlink(this.debugLogPath, function() {});
this.setLoggers(loggers);
this.setLogLevel(this.initialConfig.logLevel);
this.on('log', function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return docpad.log.apply(this, args);
});
if (err && docpad.getDebugging()) {
locale = docpad.getLocale();
return docpad.log('warn', locale.reportError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
}
});
this.trackRunnerInstance = new TaskGroup().run().on('complete', function(err) {
var locale, _ref2;
if (err && docpad.getDebugging()) {
locale = docpad.getLocale();
return docpad.log('warn', locale.trackError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
}
});
if ((loggers = instanceConfig.loggers)) {
delete instanceConfig.loggers;
} else {
logger = new (require('caterpillar').Logger)({
lineOffset: 2
});
loggerConsole = logger.pipe(new (require('caterpillar-filter').Filter)).pipe(new (require('caterpillar-human').Human));
loggers = {
logger: logger,
console: loggerConsole
};
}
safefs.unlink(this.debugLogPath, function() {});
this.setLoggers(loggers);
this.setLogLevel(this.initialConfig.logLevel);
this.on('log', function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return docpad.log.apply(this, args);
});