Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function updatePosts () {
console.log('starting update-posts')
console.log(`reading posts in dir "${dir}"`)
const postList = await readPosts(dir)
console.log('finished reading posts')
console.log(`synchronizing ${postList.length} posts`)
const {created, destroyed} = await syncPosts(models, postList)
console.log(`added ${created} ${inflection.inflect('post', created)}`)
console.log(`deleted ${destroyed} ${inflection.inflect('post', destroyed)}`)
console.log('finished updating posts')
try {
// Destroy all database connections so it finishes faster
await models.sequelize.connectionManager.pool.destroyAllNow()
} catch (err) {}
}
.map(c => c.name);
var forgottenChannels = slackChannels
.filter(c => c.is_member)
.filter(c => settings.channels.indexOf(c.name) == -1)
.map(c => c.name);
var validChannels = settings.channels
.filter(c => unwatchableChannels.indexOf(c) == -1 && forgottenChannels.indexOf(c) == -1);
this.channels = validChannels;
if(unwatchableChannels.length > 0) {
logger.warn('Bot', `Whoa! I'm trying to watch ${inflection.inflect('', unwatchableChannels.length, 'a channel', 'channels')}${inflection.inflect('', unwatchableChannels.length, '', ' in')} which I'm not a member of: ${unwatchableChannels.join(', ')}`);
}
if(forgottenChannels.length > 0) {
logger.warn('Bot', `Hey! I belong to ${inflection.inflect('an', forgottenChannels.length, null, 'some')} unwatched ${inflection.inflect('channel', forgottenChannels.length)}: ${forgottenChannels.join(', ')}`);
}
if(validChannels.length === 0) {
logger.error('Bot', 'Hmm. Looks like I have nothing to watch! Nothing to do! Yay! See you later, alligator.');
process.exit(1);
return;
} else {
logger.info('Bot', `Okay, I will watch ${inflection.inflect('', validChannels.length, 'this', 'these')} ${inflection.inflect('channel', validChannels.length)}: ${validChannels.join(', ')}`);
}
// Defines which message types must be accepted
this.expectedMessages = ['message', 'reaction_added', 'reaction_removed', 'emoji_changed',
'group_joined', 'channel_joined', 'message_deleted'];
/**
* Messages which type is defined in this array are checked against the list of watched
if (['tag', 'version', 'range'].includes(spec.type) && name && bundledNativeModules[name]) {
// Unimodule packages from npm registry are modified to use the bundled version.
const version = bundledNativeModules[name];
const modifiedSpec = `${name}@${version}`;
nativeModules.push(modifiedSpec);
return modifiedSpec;
} else {
// Other packages are passed through unmodified.
others.push(spec.raw);
return spec.raw;
}
});
const messages = [];
if (nativeModules.length > 0) {
messages.push(
`${nativeModules.length} SDK ${exp.sdkVersion} compatible native ${inflect(
'modules',
nativeModules.length
)}`
);
}
if (others.length > 0) {
messages.push(`${others.length} other ${inflect('packages', others.length)}`);
}
log(`Installing ${messages.join(' and ')} using ${packageManager.name}.`);
await packageManager.addAsync(...versionedPackages);
}
if (options.showResponseForDeleteRequest) this.showResponseForDeleteRequest = true;
if (options.model) {
//this.model = Model(model.name);
this.model = options.model;
this.database = options.database;
if (this.model.settings.hasOwnProperty("displayName")) {
this.modelName = this.model.settings.displayName;
}
else {
// set the model name, singularizing it if the collection was provided as pluralized
this.modelName = inflection.inflect(this.model.name.charAt(0).toUpperCase() + this.model.name.substring(1), 1);
}
this.pluralizedName = inflection.inflect(this.modelName, 2);
}
else if (options.route) {
this.route = options.route;
this.routeConfig = this.route.config ? this.route.config() : {};
this.modelName = this.path;
// if (this.route.config) {
// var config = this.route.config();
// if (config.route) {
// this.path = config.route;
// }
// }
}
}
.map(c => c.name);
var forgottenChannels = slackChannels
.filter(c => c.is_member)
.filter(c => settings.channels.indexOf(c.name) == -1)
.map(c => c.name);
var validChannels = settings.channels
.filter(c => unwatchableChannels.indexOf(c) == -1 && forgottenChannels.indexOf(c) == -1);
this.channels = validChannels;
if(unwatchableChannels.length > 0) {
logger.warn('Bot', `Whoa! I'm trying to watch ${inflection.inflect('', unwatchableChannels.length, 'a channel', 'channels')}${inflection.inflect('', unwatchableChannels.length, '', ' in')} which I'm not a member of: ${unwatchableChannels.join(', ')}`);
}
if(forgottenChannels.length > 0) {
logger.warn('Bot', `Hey! I belong to ${inflection.inflect('an', forgottenChannels.length, null, 'some')} unwatched ${inflection.inflect('channel', forgottenChannels.length)}: ${forgottenChannels.join(', ')}`);
}
if(validChannels.length === 0) {
logger.error('Bot', 'Hmm. Looks like I have nothing to watch! Nothing to do! Yay! See u later, alligator.');
process.exit(1);
return;
} else {
logger.info('Bot', `Okay, I will watch ${inflection.inflect('', validChannels.length, 'this', 'these')} ${inflection.inflect('channel', validChannels.length)}: ${validChannels.join(', ')}`);
}
slack
.on('raw_message', msg => this.onRawMessage(msg))
.on('message', msg => this.enqueue(msg));
}
var unwatchableChannels = slackChannels
.filter(c => settings.channels.indexOf(c.name) > -1)
.filter(c => !c.is_member)
.map(c => c.name);
var forgottenChannels = slackChannels
.filter(c => c.is_member)
.filter(c => settings.channels.indexOf(c.name) == -1)
.map(c => c.name);
var validChannels = settings.channels
.filter(c => unwatchableChannels.indexOf(c) == -1 && forgottenChannels.indexOf(c) == -1);
this.channels = validChannels;
if(unwatchableChannels.length > 0) {
logger.warn('Bot', `Whoa! I'm trying to watch ${inflection.inflect('', unwatchableChannels.length, 'a channel', 'channels')}${inflection.inflect('', unwatchableChannels.length, '', ' in')} which I'm not a member of: ${unwatchableChannels.join(', ')}`);
}
if(forgottenChannels.length > 0) {
logger.warn('Bot', `Hey! I belong to ${inflection.inflect('an', forgottenChannels.length, null, 'some')} unwatched ${inflection.inflect('channel', forgottenChannels.length)}: ${forgottenChannels.join(', ')}`);
}
if(validChannels.length === 0) {
logger.error('Bot', 'Hmm. Looks like I have nothing to watch! Nothing to do! Yay! See u later, alligator.');
process.exit(1);
return;
} else {
logger.info('Bot', `Okay, I will watch ${inflection.inflect('', validChannels.length, 'this', 'these')} ${inflection.inflect('channel', validChannels.length)}: ${validChannels.join(', ')}`);
}
slack
.on('raw_message', msg => this.onRawMessage(msg))
.on('squeezing', (files) => {
log(`Squeezing ${files.length} ${inflect('file', files.length)}...`)
})
.on('squeezed', (context) => {
.on('squeezing', (files) => {
log(`Squeezing ${files.length} ${inflect('file', files.length)}...`)
})
.on('squeezed', (context) => {
className={classes.deleteButton}
{...sanitizeRestProps(rest)}
>
{icon}
);
};
let rpt = report[type];
for (let file of rpt.files) {
let missing = [].concat(file.missing || []);
let msg = log.bold(' · ') + file.relative + ' ';
if (missing.length > 0) {
names = union([], names, missing);
msg += log.error + log.gray(' (' + missing.join(', ') + ')');
} else {
msg += log.success;
}
arr.push(msg);
}
let name = inflection.inflect(type, names.length);
message.push('', log.heading(`Missing ${names.length} ${name}`));
message.push(...arr);
}
return message.join('\n');
};