Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.handler = (argv) => {
const key = argv.key
let value = null
tools.checkConfig(CFILE)
const config = noon.load(CFILE)
const theme = themes.loadTheme(config.theme)
if (config.verbose) themes.label(theme, 'down', 'Configuration')
if (dot.has(config, key)) {
value = /\./i.test(key) ? dot.get(config, key) : config[key]
} else {
throw new Error(`Option ${key} not found.`)
}
console.log(`Option ${chalk.white.bold(key)} is ${chalk.white.bold(value)}.`)
}
exports.handler = (argv) => {
const key = argv.key
let value = null
tools.checkConfig(CFILE)
const config = noon.load(CFILE)
const theme = themes.loadTheme(config.theme)
if (config.verbose) themes.label(theme, 'down', 'Configuration')
if (dot.has(config, key)) {
value = /\./i.test(key) ? dot.get(config, key) : config[key]
} else {
throw new Error(`Option ${key} not found.`)
}
console.log(`Option ${chalk.white.bold(key)} is ${chalk.white.bold(value)}.`)
}
exports.loadTheme = (theme) => {
let dirExists = null
let load = null
try {
fs.statSync('themes')
dirExists = true
} catch (e) {
if (e.code === 'ENOENT') dirExists = false
}
const CFILE = `${process.env.HOME}/.iloa.noon`
const config = noon.load(CFILE)
if (!dirExists && config.verbose) console.log(chalk.white(`${process.cwd()}/themes does not exist, falling back to ${process.env.NODE_PATH}/iloa/themes.`))
load = noon.load(`${TDIR}${theme}.noon`)
return load
}
exports.loadTheme = (theme) => {
let dirExists = null
let load = null
try {
fs.statSync('themes')
dirExists = true
} catch (e) {
if (e.code === 'ENOENT') dirExists = false
}
const CFILE = `${process.env.HOME}/.leximaven.noon`
const config = noon.load(CFILE)
if (!dirExists && config.verbose) console.log(chalk.white(`${process.cwd()}/themes does not exist, falling back to ${process.env.NODE_PATH}/leximaven/themes.`))
load = noon.load(`${TDIR}${theme}.noon`)
return load
}
*/exports.loadTheme=function(theme){var dirExists=null;var load=null;try{fs.statSync('themes');dirExists=true;}catch(e){if(e.code==='ENOENT')dirExists=false;}var CFILE=process.env.HOME+'/.iloa.noon';var config=noon.load(CFILE);if(!dirExists&&config.verbose)console.log(chalk.white(process.cwd()+'/themes does not exist, falling back to '+process.env.NODE_PATH+'/iloa/themes.'));load=noon.load(''+TDIR+theme+'.noon');return load;};/**
* Gets themes for list command
*/exports.loadTheme=function(theme){var dirExists=null;var load=null;try{fs.statSync('themes');dirExists=true;}catch(e){if(e.code==='ENOENT')dirExists=false;}var CFILE=process.env.HOME+'/.leximaven.noon';var config=noon.load(CFILE);if(!dirExists&&config.verbose)console.log(chalk.white(process.cwd()+'/themes does not exist, falling back to '+process.env.NODE_PATH+'/leximaven/themes.'));load=noon.load(''+TDIR+theme+'.noon');return load;};/**
* Gets themes for list command
exports.loadTheme = (theme) => {
let dirExists = null
let load = null
try {
fs.statSync('themes')
dirExists = true
} catch (e) {
if (e.code === 'ENOENT') dirExists = false
}
const CFILE = `${process.env.HOME}/.iloa.noon`
const config = noon.load(CFILE)
if (!dirExists && config.verbose) console.log(chalk.white(`${process.cwd()}/themes does not exist, falling back to ${process.env.NODE_PATH}/iloa/themes.`))
load = noon.load(`${TDIR}${theme}.noon`)
return load
}
*/exports.outFile=function(path,force,tofile){var match=path.match(/\.([a-z]*)$/i);var ext=match[1];var builder=new xml2js.Builder();if(ext==='xml'){if(checkOutfile(path)){if(force){var xml=builder.buildObject(tofile);var fd=fs.openSync(path,'w+');fs.writeSync(fd,xml);fs.closeSync(fd);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{var _xml=builder.buildObject(tofile);var _fd=fs.openSync(path,'w+');fs.writeSync(_fd,_xml);fs.closeSync(_fd);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext==='cson'||ext==='json'||ext==='noon'||ext==='plist'||ext==='yml'||ext==='yaml'){if(checkOutfile(path)){if(force){noon.save(path,tofile);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{noon.save(path,tofile);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext!=='xml'||ext!=='cson'||ext!=='json'||ext!=='noon'||ext!=='plist'||ext!=='yml'||ext!=='yaml')throw new Error('Format '+ext+' not supported.');};
*/exports.outFile=function(path,force,tofile){var match=path.match(/\.([a-z]*)$/i);var ext=match[1];var builder=new xml2js.Builder();if(ext==='xml'){if(checkOutfile(path)){if(force){var xml=builder.buildObject(tofile);var fd=fs.openSync(path,'w+');fs.writeSync(fd,xml);fs.closeSync(fd);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{var _xml=builder.buildObject(tofile);var _fd=fs.openSync(path,'w+');fs.writeSync(_fd,_xml);fs.closeSync(_fd);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext==='cson'||ext==='json'||ext==='noon'||ext==='plist'||ext==='yml'||ext==='yaml'){if(checkOutfile(path)){if(force){noon.save(path,tofile);console.log(chalk.white('Overwrote '+path+' with data.'));}else console.log(chalk.white(path+' exists, use -f to force overwrite.'));}else{noon.save(path,tofile);console.log(chalk.white('Wrote data to '+path+'.'));}}else if(ext!=='xml'||ext!=='cson'||ext!=='json'||ext!=='noon'||ext!=='plist'||ext!=='yml'||ext!=='yaml')throw new Error('Format '+ext+' not supported.');};
} else console.log(chalk.white(`${path} exists, use -f to force overwrite.`))
} else {
const xml = builder.buildObject(tofile)
const fd = fs.openSync(path, 'w+')
fs.writeSync(fd, xml)
fs.closeSync(fd)
console.log(chalk.white(`Wrote data to ${path}.`))
}
} else if (ext === 'cson' || ext === 'json' || ext === 'noon' || ext === 'plist' || ext === 'yml' || ext === 'yaml') {
if (checkOutfile(path)) {
if (force) {
noon.save(path, tofile)
console.log(chalk.white(`Overwrote ${path} with data.`))
} else console.log(chalk.white(`${path} exists, use -f to force overwrite.`))
} else {
noon.save(path, tofile)
console.log(chalk.white(`Wrote data to ${path}.`))
}
} else if (ext !== 'xml' || ext !== 'cson' || ext !== 'json' || ext !== 'noon' || ext !== 'plist' || ext !== 'yml' || ext !== 'yaml') throw new Error(`Format ${ext} not supported.`)
}