How to use the process.argv function in process

To help you get started, we’ve selected a few process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM-Blockchain / blockchain-vscode-extension / .azure / rewritePackageJson.js View on Github external
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
'use strict';

// NOTE: this file is also used by the engagement team so be careful when changing it

const fs = require('fs');
const process = require('process');

console.log('rewriting package json');

const packageJson = JSON.parse(fs.readFileSync('./package.json'));

if (process.argv.includes('publish')) {
  packageJson.production = true;
  packageJson.activationEvents = ['*'];
} else {
  if (packageJson.activationEvents.length > 1) {
    throw new Error('Activation events should be * when checked in');
  }

  if (packageJson.engines.vscode !== '^1.38.0') {
    throw new Error('Engine vscode should be ^1.38.0 when checked in');
  }

  packageJson.activationEvents = [];

  packageJson.actualActivationEvents.onView.forEach((event) => {
    packageJson.activationEvents.push('onView:' + event);
  });
github Kashomon / gpub / cmd / gpub.js View on Github external
.action(function(options) {
    if (!options) {
      console.log('Must define options (at least files).')
      return
    }
    if (!options.files && !options.inputDir) {
      console.log('One of --files or --input_dir must be defined')
      return
    }
    if (!options.outputDir) {
      options.outputDir = process.cwd()
    }
    parser.parse(options)
  });

program.parse(process.argv);

if (!program.args.length) program.help();

var cmdArg = program.args[0];
// This feels like a massive hack but this commander thing doesn't have good
// fallback logic.
if (!cmds[cmdArg] && typeof cmdArg !== 'object') {
  console.error('Unknown command: ' + cmdArg)
  program.help();
}
github dbjorge / jorbs-spire-mod / scripts / generate-card-images.js View on Github external
//
// This requires "magick" be present on your path to run. On Windows, you can get it by installing Chocolatey and
// then running "choco install imagemagick"
//
// Usage (regenerate all cards):
//     node generate-card-images.js
//
// Usage (regenerate only cards whose paths match a given substring):
//     node generate-card-images.js SomeSubstring

const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const process = require('process');

const cardFilterSubstring = process.argv.length > 2 ? process.argv[2] : null;

const cardMasksByCardType = {
  'ATTACK': path.join(__dirname, 'card_masks/attack.png'),
  'SKILL': path.join(__dirname, 'card_masks/skill.png'),
  'POWER': path.join(__dirname, 'card_masks/power.png'),
  'STATUS': path.join(__dirname, 'card_masks/skill.png'),
  'CURSE': path.join(__dirname, 'card_masks/skill.png'),
};

const inputDirectory = path.join(__dirname, '../src/main/resources/stsjorbsmodResources/images/cards/originals');
const outputDirectory = path.join(__dirname, '../src/main/resources/stsjorbsmodResources/images/cards/generated');
const srcDirectory = path.join(__dirname, '../src/main/java/stsjorbsmod/cards');

function findFilesRecursiveSync(directory, filePattern) {
  const results = [];
  const shallowFiles = fs.readdirSync(directory);
github ThisIsManta / stylus-supremacy / test / runner.js View on Github external
})

jasmine.configureDefaultReporter({
	showColors: false
})

const glob = require('glob')
const ps = require('process')
const fs = require('fs')
const pt = require('path')
const _ = require('lodash')
const Stylus = require('stylus')
const format = require('../edge/format')
const compareContent = require('../edge/compareContent')

const filesAndDirectories = _.chain(ps.argv.length > 2 ? ps.argv.slice(2) : ['*']).map(para => glob.sync('spec/' + para)).flatten().value()
const filesOnly = path => pt.extname(path) === '.js'
const directoriesOnly = path => pt.extname(path) === ''

filesAndDirectories.filter(directoriesOnly).forEach(directory => {
	const optionFilePath = pt.join(directory, 'formattingOptions.json')
	const inputFilePath = pt.join(directory, 'input.styl')
	const inputFormattedFilePath = pt.join(directory, 'input-formatted.styl')
	const inputDebuggingFilePath = pt.join(directory, 'input-debugging.json')
	const outputFilePath = pt.join(directory, 'output.styl')
	const outputFormattedFilePath = pt.join(directory, 'output-formatted.styl')
	const outputDebuggingFilePath = pt.join(directory, 'output-debugging.json')

	const inputContent = fs.readFileSync(inputFilePath, 'utf8')
	const outputContent = fs.readFileSync(outputFilePath, 'utf8')

	let formattingOptions = undefined
github ThisIsManta / stylus-supremacy / edge / commandLineInterface.js View on Github external
#!/usr/bin/env node

const ps = require('process')

const process = require('./commandLineProcessor')

const errors = process(ps.argv[2], ps.argv.slice(3))
if (errors.length > 0) {
	console.error(`Done with ${errors.length} error${errors.length === 1 ? '' : 's'}.`)
	ps.exit(1)
}
github GoogleChromeLabs / confluence / main / relational_to_compat.es6.js View on Github external
[class package path].json in [repository root]/data, with class model files in
class:[class package path].json.

USAGE:

    node /path/to/relationship_to_compat.es6.js BaseConfluenceDataURL

        BaseConfluenceDataURL = absolute https: or file: URL to directory
                                where Confluence data are stored with NO
                                trailing slash.`;
if (process.argv.length !== 3) {
  console.error(USAGE);
  process.exit(1);
}

const dataUrl = url.parse(process.argv[2]);
if (dataUrl.protocol !== 'file:' && dataUrl.protocol !== 'https:') {
  console.error('BaseConfluenceDataURL parameter must be file: or https: URL');
}

const container = pkg.JsonDAOContainer.create({
  mode: dataUrl.protocol === 'file:' ? pkg.DataSource.LOCAL :
      pkg.DataSource.HTTP,
  basename: dataUrl.protocol === 'file:' ? dataUrl.pathname :
      url.format(dataUrl),
}, logger);

logger.info('Gathering Confluence data from JSON');

const dataOutputter = foam.json.Outputter.create({
  passPropertiesByReference: true,
  pretty: false,
github CodeChain-io / codechain-keystore-cli / src / index.ts View on Github external
cckey create -t platform --passphrase "my password"

    cckey list -t asset

    cckey delete -t platform --address "ccc..."

    cckey import UTC--2018-08-14T06-30-23Z--bbb6685e-7165-819d-0988-fc1a7d2d0523 -t platform --passphrase "satoshi"

    cckey export -t platform --address cccq8ah0efv5ckpx6wy5mwva2aklzwsdw027sqfksrr --passphrase "satoshi"

    cckey import-raw -t platform a05f81608217738d99da8fd227897b87e8890d3c9159b559c7c8bbd408e5fb6e --passphrase "satoshi"
`);
});

program.parse(process.argv);
if (program.args.length === 0) {
    program.outputHelp();
    process.exit(1);
}

function parseAccountType(accountType: string): AccountType {
    if (_.isUndefined(accountType)) {
        throw new CLIError(CLIErrorType.OptionRequired, {
            optionName: "account-type"
        });
    }
    if (!_.includes(["platform", "asset"], accountType)) {
        throw new CLIError(CLIErrorType.InvalidAccountType);
    }
    return accountType as AccountType;
}
github microsoft / azure-pipelines-artifact-caching-tasks / gulpfile.js View on Github external
function make(target, cb) {
  var cl = (
    "node make.js " +
    target +
    " " +
    process.argv.slice(3).join(" ")
  ).trim();
  console.log("------------------------------------------------------------");
  console.log("> " + cl);
  console.log("------------------------------------------------------------");
  try {
    child_process.execSync(cl, { cwd: __dirname, stdio: "inherit" });
  } catch (err) {
    var msg = err.output ? err.output.toString() : err.message;
    console.error(msg);
    cb(new gutil.PluginError(msg));
    return false;
  }

  return true;
}
github protofire / solhint / solhint.js View on Github external
.option('-q, --quiet', 'report errors only')
    .description('Linter for Solidity programming language')
    .action(execMainAction)

  program
    .command('stdin')
    .description('linting of source code data provided to STDIN')
    .option('--filename [file_name]', 'name of file received using STDIN')
    .action(processStdin)

  program
    .command('init-config')
    .description('create in current directory configuration file for solhint')
    .action(writeSampleConfigFile)

  program.parse(process.argv)

  if (program.args.length < 1) {
    program.help()
  }
}
github mongodb / marian / src / index.js View on Github external
async function main() {
    Logger.setLevel('info', true)

    const server = new Marian(process.argv[2])
    server.start(8080)
}