Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import getStdin from 'get-stdin';
getStdin().then((str: string) => {});
getStdin.buffer().then((str: Buffer) => {});
// $ExpectError
(getStdin(): number);
// $ExpectError
(getStdin.buffer(): number);
const run = (program: ProgramArgs): void => {
if (program.args && program.args.length > 0) {
return parseAndReportFiles(program.args, program);
}
if (process.stdin.isTTY) {
return program.help();
}
// data is coming from a pipe
getStdin()
.then(function(content: string) {
const todos = parseContentSync(content, program);
outputTodos(todos, program);
})
.catch(function(e) {
console.error(e);
process.exit(1);
});
};
letters. Adjust variance like 'n10/2'.
c Word class. Restrict this word to a word class:
- J for adjective
- N for noun
- R for adverb
- V for verb
a Alliterate (word rhyme) up to and including this word,
e.g. allow 'cheshire cat' but not 'cheshire dog'.
Examples
$ cat myfile.txt | codenamer
$ curl -s https://en.wikipedia.org/wiki/Batman | codenamer
$ curl -s https://en.wikipedia.org/wiki/Batman | codenamer --format pa-a,n15
`, minimistOptions);
getStdin().then(input => {
if (!input) {
/* eslint no-console:0 */
console.error('ERR: No input given');
console.log(cli.help);
process.exit(0);
}
const options = Object.assign({}, defaults, cli.flags);
const output = codenamer(options.format.split('-'), input, options.count);
console.log(output.map(code => code.join('-')).join('\n'));
});
const handleStdin = (argv) => {
/* eslint-disable no-unused-expressions */
yargs
/* eslint-enable */
.demand(0, 0)
.argv;
getStdin()
.then((stdin) => {
const result = fixText(stdin, {
syntax: argv.syntax
});
/* eslint-disable no-console */
console.log(result);
/* eslint-enable */
});
};
const handleStdin = (argv) => {
/* eslint-disable no-unused-expressions */
yargs
/* eslint-enable */
.demand(0, 0)
.argv;
getStdin()
.then((stdin) => {
const report = lintText(stdin, {
filePath: argv.filePath,
syntax: argv.syntax
});
outputReport({
errorCount: report.errorCount,
results: [
report
],
warningCount: report.warningCount
}, argv.outputFormat);
});
};
#!/usr/bin/env node
import parse from "./parse";
import getStdin from "get-stdin";
getStdin()
.then(async str => {
const output = await parse(
process.argv.slice(2),
str.replace(/\n$/, "").split("\n")
);
if (output.mustPrint) {
if (Array.isArray(output.result)) {
output.result.forEach(i => console.log(i));
} else {
console.log(output.result);
}
}
process.exit(0);
})
.catch(error => {
console.error(error.message);
})
}
const invig = new Invig({
src : program.src,
check : program.check,
dryrun: program.dryrun,
bail : program.bail,
init : program.init,
quiet : program.quiet,
npmBinDir,
es7 : program.es7,
})
if (program.src === '-') {
getStdin().then(stdin => {
invig
.runOnStdIn(stdin)
.catch(err => {
scrolex.failure(`${err}`)
process.exit(1)
})
.then(() => {
scrolex.success(`Done`)
})
})
} else {
invig
.runOnPattern()
.catch(err => {
scrolex.failure(`${err}`)
process.exit(1)
const options = parseOptions()
if (options.command === 'generate-config') {
return setup(options)
}
const diff = await getDiffInformation(options)
if (options.command === 'list-files') {
return console.log(_.keys(diff).join(' '))
}
if (!options.command) {
let result
if (_.isEmpty(options.files)) {
const input = await stdin()
if (input === '') {
throw new Error('stdin was empty')
}
result = await checkString(diff, input, options)
} else {
result = await checkFiles(diff, options.files, options)
}
return handleResult(result, options)
}
throw new Error(`Unknown command '${options.command}'`)
}
#!/usr/bin/env node
import program from 'commander';
import { readFile } from 'fs-promise';
import getStdin from 'get-stdin';
import { version } from '../package.json';
import htconvert from './htconvert';
program
.version(version)
.option('-f, --file [.htaccess]', 'File containing .htaccess redirects')
.parse(process.argv);
const readHtaccess = program.file ? readFile(program.file, 'utf-8') : getStdin();
readHtaccess
.then(htaccess => htaccess ? htconvert(htaccess) : program.help())
.then(console.log);
options.topLevelModule ? null : options.moduleName,
code,
{},
options.reactImport
);
process.stdout.write(result);
};
if (options.file) {
fs.readFile(options.file, (err, data) => {
if (err) {
throw err;
}
processInput(data.toString());
});
} else {
getStdin().then(processInput);
}
}