This commit is contained in:
2026-05-13 19:58:16 +03:00
commit f5adeb292b
78 changed files with 12024 additions and 0 deletions

32
lib/rocketchat/start.js Normal file
View File

@@ -0,0 +1,32 @@
const datafile = require('../datafile')
const fs = require('fs');
//
// Initialize the child logger for
// the module
//
const log = require('../log').child({
module: 'start'
})
module.exports = async function(context) {
log.info('preparing files paths')
const dest = context.config.target.filesPath
if (!dest || !fs.existsSync(dest)) {
fs.mkdirSync(dest)
}
if (!fs.lstatSync(dest).isDirectory() || fs.accessSync(dest, fs.constants.W_OK)) {
throw new Error(`Directory "${dest} is not writable"`)
}
log.info('connecting to rocketchat')
await context.rocketchat.connect(context.config)
log.info(`creating file '${context.config.target.filename}'`)
// Create the datafile and add it to the context
context.output = datafile(
context.config.target.filename,
process.exit
)
return context
}