How to use read-pkg - 10 common examples

To help you get started, we’ve selected a few read-pkg 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 simpleweb / romulus-cli / generators / base / index.js View on Github external
//  copy shell scripts
    this.fs.copyTpl(
      this.templatePath('bin/bump-ios.sh'),
      this.destinationPath('bin/bump-ios.sh'),
      { name: this.name }
    );

    //  copy android files
    this.fs.copyTpl(
      this.templatePath('android/MainActivity.java'),
      this.destinationPath(`android/app/src/main/java/com/${this.name.toLowerCase()}/MainActivity.java`),
      { name: this.name, nameLower: this.name.toLowerCase() }
    );

    // merge the two package json files
    const currentPackage = readPkg.sync();

    writePkg.sync(
      deepExtend(currentPackage, {
        "private": true,
        "scripts": {
          "pretty": "prettier --config .prettierrc.js --write '**/*.js'",
          "lint": "eslint --fix './App/**/*.js'",
          "bump": "./bin/bump-ios.sh",
          "test": "jest --verbose",
          "coverage": "jest --coverage",
          "test:watch": "npm test -- --watch",
          "pretest": "yarn run lint"
        },
        "lint-staged": {
          "App/**/*.js": ["yarn run pretty", "yarn run lint", "git add"]
        },
github pvdlg / uprogress / build / karma.config-ci.js View on Github external
/* eslint-env node */

const pkg = require('read-pkg').sync();

module.exports = config => {
	const customLaunchers = require('./sauce-browsers.config.js');

	require('./karma.config.js')(config);
	config.reporters.push('saucelabs');
	config.set({
		autoWatch: false,
		sauceLabs: {
			testName: `${pkg.name} unit tests`,
			recordVideo: true,
			recordScreenshots: true,
		},
		customLaunchers,
		browsers: Object.keys(customLaunchers),
		captureTimeout: 300000,
github posva / rollit / lib / utils.js View on Github external
const uppercamelcase = require('uppercamelcase')
const findRoot = require('find-root')
const readPkg = require('read-pkg')
const fs = require('fs')
const { pwd } = require('shelljs')
const { join } = require('path')

const cwd = pwd().toString()
const root = findRoot(cwd)
const packagePath = join(root, 'package.json')
const { author: _author, name, version, contributors: _contributors } = readPkg.sync(packagePath)

// TODO real package for author to string
const stringifyAuthor = a => a && `${a.name} <${a.email}>`
const contributors = _contributors && _contributors.map(stringifyAuthor).join(', ')
const author = stringifyAuthor(_author)

function generateBanner (useContributors) {
  const creator = author || contributors
  return `/**
 * ${name} v${version}` +
 (creator ? `
 * (c) ${new Date().getFullYear()} ${(useContributors ? contributors : author) || creator}` : '') + `
 * @license MIT
 */
`
}
github prettier / prettier-atom / src / helpers.js View on Github external
const getDebugInfo = () => ({
  atomVersion: atom.getVersion(),
  prettierAtomVersion: readPkg.sync().version,
  prettierVersion: readPkg.sync(getDepPath('prettier')).version,
  prettierESLintVersion: readPkg.sync(getDepPath('prettier-eslint')).version,
  prettierAtomConfig: atom.config.get('prettier-atom'),
});
github Enalean / tuleap / tools / utils / scripts / component-builder.js View on Github external
function verifyPackageJsonFile(component_path) {
    const package_json_path = path.join(component_path, "package.json");

    const package_json = readPkg.sync({ cwd: component_path });
    if (!package_json.name) {
        throw new Error("package.json file should have a 'name' " + package_json_path);
    }

    if (!package_json.scripts || !package_json.scripts.build) {
        throw new Error("package.json file should have a 'build' script " + package_json_path);
    }

    return {
        name: package_json.name,
        path: component_path
    };
}
github tchaguitos / correios-rest / node_modules / nyc / node_modules / read-pkg-up / index.js View on Github external
module.exports.sync = options => {
	const fp = findUp.sync('package.json', options);

	if (!fp) {
		return {};
	}

	return {
		pkg: readPkg.sync(fp, options),
		path: fp
	};
};
github webiny / webiny-js / scripts / private.js View on Github external
.map(dir => {
        const pkg = readPkg.sync({ cwd: dir, normalize: false });
        return {
            name: pkg.name,
            location: path.join(process.cwd(), dir),
            package: pkg
        };
    })
    .filter(pkg => !pkg.package.private && toPublish.includes(pkg.name));
github Autodesk / hig / packages / semantic-release-config / index.js View on Github external
const readPkg = require("read-pkg");
const createReleaseConfig = require("./build/index").default;

const packageName = readPkg.sync().name;

module.exports = createReleaseConfig({ packageName });
github bellingard / sonar-scanner-npm / dist / sonarqube-scanner-params.js View on Github external
function extractInfoFromPackageFile(sonarqubeScannerParams, projectBaseDir) {
  var packageFile = path.join(projectBaseDir, 'package.json')
  var pkg = readPackage(packageFile)
  log('Getting info from "package.json" file')
  function fileExistsInProjectSync(file) {
    return fs.existsSync(path.resolve(projectBaseDir, file))
  }
  function dependenceExists(pkgName) {
    return ['devDependencies', 'dependencies', 'peerDependencies'].some(function(prop) {
      return pkg[prop] && pkgName in pkg[prop]
    })
  }
  if (pkg) {
    sonarqubeScannerParams['sonar.projectKey'] = slugify(pkg.name, {
      remove: invalidCharacterRegex
    })
    sonarqubeScannerParams['sonar.projectName'] = pkg.name
    sonarqubeScannerParams['sonar.projectVersion'] = pkg.version
    if (pkg.description) {

read-pkg

Read a package.json file

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis

Popular read-pkg functions