Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
/* eslint-disable no-unused-vars */
const should = require('should');
const packageName = require('./utils/publish-please-version-under-test');
const reporter = require('../lib/reporters/elegant-status-reporter');
const rename = require('fs').renameSync;
const pathJoin = require('path').join;
const emoji = require('node-emoji').emoji;
const chalk = require('chalk');
const envType = require('../lib/reporters/env-type');
const lineSeparator = '----------------------------------';
describe('Elegant status reporter', () => {
let nativeExit;
let nativeConsoleLog;
let nativeIsCI;
let exitCode;
let output;
beforeEach(() => {
console.log(`${lineSeparator} begin test ${lineSeparator}`);
exitCode = undefined;
output = '';
nativeExit = process.exit;
it('Should report a succeeded process', () => {
// Given
const message = 'yo process passed';
// When
reporter.reportSucceededProcess(message);
// Then
if (typeof process.env.APPVEYOR === 'undefined') {
output.should.containEql(emoji.tada);
}
});
callThroughHook('linkStep', async () => {
// remove integrity hash to make this operation atomic
await this.integrityChecker.removeIntegrityFile();
this.reporter.step(curr, total, this.reporter.lang('linkingDependencies'), emoji.get('link'));
flattenedTopLevelPatterns = this.preparePatternsForLinking(
flattenedTopLevelPatterns,
manifest,
this.config.lockfileFolder === this.config.cwd,
);
await this.linker.init(flattenedTopLevelPatterns, workspaceLayout, {
linkDuplicates: this.flags.linkDuplicates,
ignoreOptional: this.flags.ignoreOptional,
});
}),
);
// init
reporter.step(2, 4, reporter.lang('whyInitGraph'), emoji.get('truck'));
const lockfile = yield (_wrapper || _load_wrapper()).default.fromDirectory(config.cwd, reporter);
const install = new (_install || _load_install()).Install(flags, config, reporter, lockfile);
var _ref7 = yield install.fetchRequestFromCwd();
const depRequests = _ref7.requests,
patterns = _ref7.patterns;
yield install.resolver.init(depRequests, install.flags.flat);
const hoisted = yield install.linker.getFlatHoistedTree(patterns);
// finding
reporter.step(3, 4, reporter.lang('whyFinding'), emoji.get('mag'));
let match;
for (const _ref8 of hoisted) {
var _ref9 = (0, (_slicedToArray2 || _load_slicedToArray()).default)(_ref8, 2);
const loc = _ref9[0];
const info = _ref9[1];
if (info.key === query || info.previousKeys.indexOf(query) >= 0) {
match = [loc, info];
break;
}
}
if (!match) {
reporter.error(reporter.lang('whyUnknownMatch'));
throw new MessageError(reporter.lang('moduleNotInManifest'));
}
}
// save manifests
await config.saveRootManifests(rootManifests);
// run hooks - npm runs these one after another
for (const action of ['preuninstall', 'uninstall', 'postuninstall']) {
for (const [loc] of manifests) {
await config.executeLifecycleScript(action, loc);
}
}
// reinstall so we can get the updated lockfile
reporter.step(++step, totalSteps, reporter.lang('uninstallRegenerate'), emoji.get('hammer'));
const installFlags = {force: true, workspaceRootIsCwd: true, ...flags};
const reinstall = new Install(installFlags, config, new NoopReporter(), lockfile);
await reinstall.init();
//
reporter.success(reporter.lang('uninstalledPackages'));
}
database.ref(`guilds/${message.guild.id}/messages`).once('value', (snapshot) => {
const db = snapshot.val();
if (!db) {
error(message, '', `My records are empty!`);
return;
}
// determine emoji
filter = emoji.hasEmoji(filter)
? emoji.unemojify(filter)
: filter.match(/:\d+>/)[0];
filter = filter.substring(1, filter.length - 1);
usersInfo(message, db, filter);
}, (errorObject) => {
console.log('The read failed: ' + errorObject.code);
app.post('/', (req, res, next) => {
// check for secret token
if (!req.body.token || req.body.token !== process.env.SECRET_TOKEN) {
next();
return;
}
// store token
const token = process.env.SLACK_TOKEN;
// log some stuff for dev
console.log(req.body);
// grab status and emojis and clean it up
let status = req.body.title;
let statusEmoji = nodeEmoji.unemojify('🗓');
const statusHasEmoji = emojiRegex().exec(status);
if (statusHasEmoji) {
statusEmoji = nodeEmoji.unemojify(statusHasEmoji[0]);
console.log(`CUSTOM EMOJI! ${statusEmoji}`);
status = nodeEmoji.strip(status);
}
// additional tokens
const dndToken = '[DND]';
const awayToken = '[AWAY]';
// parse event start/stop time
const dateFormat = 'MMM D, YYYY [at] hh:mmA';
const start = moment(req.body.start, dateFormat);
const end = moment(req.body.end, dateFormat);
// check for DND
if (status.includes(dndToken)) {
slack.dnd.setSnooze({
token,
num_minutes: end.diff(start, 'minutes')
});
database.ref(`guilds/${message.guild.id}/messages`).once('value', (snapshot) => {
const db = snapshot.val();
if (!db) {
error(message, '', `My records are empty!`);
return;
}
// determine emoji
filter = emoji.hasEmoji(filter)
? emoji.unemojify(filter)
: filter.match(/:\d+>/)[0];
filter = filter.substring(1, filter.length - 1);
usersInfo(message, db, filter);
}, (errorObject) => {
console.log('The read failed: ' + errorObject.code);
public QuickNew() {
this.readConfig();
let file: string = path.normalize(path.join(this.memodir, dateFns.format(new Date(), 'YYYY-MM-DD') + ".md"));
let date: Date = new Date();
let dateFormat = this.memoDateFormat;
let getISOWeek = this.memoISOWeek == true ? "[Week: " + dateFns.getISOWeek(new Date()) + "/" + dateFns.getISOWeeksInYear(new Date()) + "] " : "";
let getEmoji = this.memoEmoji == true ? randomEmoji.random().emoji : "";
// console.log(getISOWeek);
// console.log(getEmoji);
fs.stat(file, async (err, files) => {
if (err) {
await fs.writeFile(file, "# " + dateFns.format(new Date(), `${dateFormat}`) + os.EOL + os.EOL, (err) => {
if (err) throw err;
});
}
});
// 選択されているテキストを取得
// エディタが一つも無い場合は、エラーになるので対処しておく
let editor = vscode.window.activeTextEditor;
let selectString: String = editor ? editor.document.getText(editor.selection) : "";
if (!req.body.token || req.body.token !== process.env.SECRET_TOKEN) {
next();
return;
}
// store token
const token = process.env.SLACK_TOKEN;
// log some stuff for dev
console.log(req.body);
// grab status and emojis and clean it up
let status = req.body.title;
let statusEmoji = nodeEmoji.unemojify('🗓');
const statusHasEmoji = emojiRegex().exec(status);
if (statusHasEmoji) {
statusEmoji = nodeEmoji.unemojify(statusHasEmoji[0]);
console.log(`CUSTOM EMOJI! ${statusEmoji}`);
status = nodeEmoji.strip(status);
}
// additional tokens
const dndToken = '[DND]';
const awayToken = '[AWAY]';
// parse event start/stop time
const dateFormat = 'MMM D, YYYY [at] hh:mmA';
const start = moment(req.body.start, dateFormat);
const end = moment(req.body.end, dateFormat);
// check for DND
if (status.includes(dndToken)) {
slack.dnd.setSnooze({
token,
num_minutes: end.diff(start, 'minutes')
});
status = status.replace(dndToken, '').trim();
}