Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
Fish history (~/.local/share/fish/fish_history) is in YAML format.
Parsed to JS object it looks like:
[{
cmd: './some-command',
when: 123123123
}, ...]
Zsh history looks like:
: 1482183081:0;git clone https://github.com/powerline/fonts.git
*/
const zshHistory = yamljs
.load(getUserHome() + '/.local/share/fish/fish_history')
.map(entry => `: ${entry.when}:0;${entry.cmd}`)
.join('\n');
// log to stdout to append the converted fish history to ~/.zsh_history
console.log(zshHistory);
var ERR_UNKNOWN = 0x00;
var ERR_UNSUPPORTED = 0x01;
var ERR_TOOMANY = 0x02;
var ERR_NOTFOUND = 0x03;
// Marker objects for special protocol values
var DVAL_EOM = { type: 'eom' };
var DVAL_REQ = { type: 'req' };
var DVAL_REP = { type: 'rep' };
var DVAL_ERR = { type: 'err' };
var DVAL_NFY = { type: 'nfy' };
// String map for commands (debug dumping). A single map works (instead of
// separate maps for each direction) because command numbers don't currently
// overlap. So merge the YAML metadata.
var debugCommandMeta = yaml.load('duk_debugcommands.yaml');
var debugCommandNames = []; // list of command names, merged client/target
debugCommandMeta.target_commands.forEach(function (k, i) {
debugCommandNames[i] = k;
});
debugCommandMeta.client_commands.forEach(function (k, i) { // override
debugCommandNames[i] = k;
});
var debugCommandNumbers = {}; // map from (merged) command name to number
debugCommandNames.forEach(function (k, i) {
debugCommandNumbers[k] = i;
});
// Duktape heaphdr type constants, must match C headers
var DUK_HTYPE_STRING = 0;
var DUK_HTYPE_OBJECT = 1;
var DUK_HTYPE_BUFFER = 2;
#!/usr/bin/env node
YAML = require('yamljs');
const consoleServices = YAML.load('console-services.yml');
const listItems = generate(consoleServices);
injectIntoXml(listItems);
function generate(consoleServices) {
return consoleServices.map(({command, description, icon, url}) => {
console.log(command);
const consoleService = {
title: command,
arg: url,
subtitle: description,
imagefile: icon || `${command}.png`,
};
return consoleService;
});
.action(function() {
const config = yaml.load(`${process.cwd()}/config.yml`)
const html = fs.readFileSync(`${process.cwd()}/index.html`, 'utf-8')
if (!config.title || !config.user || !config.repository || !config.perpage || !config.token) {
return console.log('Configure infomation error')
}
const content = html.replace('$config', JSON.stringify(config))
fs.outputFileSync(`${process.cwd()}/index.html`, content)
console.log('Finished building the blog')
})
async pushFlow(specPath){
let spec = {}
try {
spec = YAML.load(specPath)
} catch (err) {
throw new Error(err.message)
}
this._debugMsg('Calling source upload with spec')
this._debugMsg(spec)
const token = await this._authz('source')
const res = await this._fetch('/source/upload', token, {
method: 'POST',
body: spec
})
if (res.status === 200) {
const out = await res.json()
this._debugMsg(out)
export function getTags() {
if (fs.existsSync(getSetting('TAGS_PATH'))) {
return YAML.load(getSetting('TAGS_PATH').toString());
}
return [];
}
fileOrDefaults(type) {
const buildConfig = { src: this.config.src, dist: `${this.config.dist}-${type}`, pageList: [] }
const fpath = path.join(cwd, this.config.src, `${type}.yml`)
try {
if (fs.statSync(fpath)) {
Object.assign(buildConfig, { pageList: YAML.load(fpath) })
}
} catch (err) {
return buildConfig
}
return buildConfig
}
}
function yamlHelper(data) {
return yaml.load(escapeYAML(data.text));
}
function exposeSwaggerDoc(express: Express, docRoute: string): void {
const swaggerDocPath = path.join(__dirname, "..", "..", "swagger.yaml");
const swaggerDocument = yaml.load(swaggerDocPath);
express.use(docRoute, swaggerUi.serve, swaggerUi.setup(swaggerDocument));
}