mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 05:18:32 +08:00
43 lines
1.1 KiB
JavaScript
Executable File
43 lines
1.1 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Setup the debug paramater.
|
|
*/
|
|
|
|
process.env.DEBUG = process.env.TALK_DEBUG;
|
|
|
|
/**
|
|
* Module dependencies.
|
|
*/
|
|
|
|
const program = require('commander');
|
|
|
|
//==============================================================================
|
|
// Setting up the program command line arguments.
|
|
//==============================================================================
|
|
|
|
program
|
|
.command('init')
|
|
.description('initilizes the talk settings')
|
|
.action(() => {
|
|
const mongoose = require('../mongoose');
|
|
const Setting = require('../models/setting');
|
|
const defaults = {id: '1', moderation: 'pre'};
|
|
|
|
Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true})
|
|
.then(() => {
|
|
console.log('Created settings object.');
|
|
mongoose.disconnect();
|
|
}).catch((err) => {
|
|
console.error(`failed to create the settings object ${JSON.stringify(err)}`);
|
|
throw new Error(err); // just to be safe
|
|
});
|
|
});
|
|
|
|
program.parse(process.argv);
|
|
|
|
// If there is no command listed, output help.
|
|
if (!process.argv.slice(2).length) {
|
|
program.outputHelp();
|
|
}
|