How to use write-pkg - 10 common examples

To help you get started, we’ve selected a few write-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 Tencent / bk-cmdb / src / ui / builder / utils / sync-magicbox.js View on Github external
const sourceDep = from[dependencyKey]
    const fromDep = from[dependencyKey]
    if (fromDep) {
      const merged = to[dependencyKey] || {}
      // eslint-disable-next-line no-restricted-syntax
      for (const key in fromDep) {
        if (sourceDep && sourceDep[key]) {
          merged[key] = sourceDep[key]
        } else {
          merged[key] = fromDep[key]
        }
      }
      to[dependencyKey] = merged
    }
  })
  writePkg.sync(to)
  execSync('rm -rf src/magicbox/src')
  execSync('cp -R magicbox-temp/src src/magicbox/src')
  execSync('rm src/magicbox/src/bk-magic-ui/package.json')
  execSync('rm -rf magicbox-temp')
} catch (error) {
  console.log(error)
}
github mosjs / mos / packages / mos-init / index.js View on Github external
var cmd = 'mos' + (args.length > 0 ? ' ' + args.join(' ') : '')
  var s = pkg.scripts = pkg.scripts ? pkg.scripts : {}

  if (s.test && s.test !== DEFAULT_TEST_SCRIPT) {
    s.test = s.test.replace(/\bnode (test\/)?test\.js\b/, cmd)

    if (!/\bmos\b/.test(s.test)) {
      s.test += ' && ' + cmd
    }
  } else {
    s.test = cmd
  }
  s.md = 'mos'
  s['?md'] = 'echo "Update the markdown files"'

  writePkg.sync(pkgPath, pkg)

  var post = function () {
    // for personal use
    if (cli.indexOf('--unicorn') !== -1) {
      var pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
      pkg.devDependencies.mos = '*'
      writePkg.sync(pkgPath, pkg)
    }
  }

  if (opts.skipInstall) {
    post()
    return Promise.resolve()
  }

  var child = spawn('npm', ['install', '--save-dev', 'mos'], {
github simpleweb / romulus-cli / generators / base / index.js View on Github external
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"]
        },
        "husky": {
          "hooks": {
github mosjs / mos / packages / mos-init / index.js View on Github external
var post = function () {
    // for personal use
    if (cli.indexOf('--unicorn') !== -1) {
      var pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
      pkg.devDependencies.mos = '*'
      writePkg.sync(pkgPath, pkg)
    }
  }
github lerna / lerna / test / InitCommand.js View on Github external
cwd: testDir,
      });
      expect(GitUtilities.isInitialized).lastCalledWith(execOpts);
      expect(GitUtilities.init).lastCalledWith(execOpts);

      expect(writeJsonFile.sync).lastCalledWith(
        path.join(testDir, "lerna.json"),
        {
          lerna: lernaVersion,
          packages: ["packages/*"],
          version: "0.0.0",
        },
        { indent: 2 }
      );

      expect(writePkg.sync).lastCalledWith(
        path.join(testDir, "package.json"),
        expect.objectContaining({
          devDependencies: {
            lerna: `^${lernaVersion}`,
          },
        })
      );

      expect(FileSystemUtilities.mkdirpSync).lastCalledWith(path.join(testDir, "packages"));
    });
github lerna / lerna / test / PublishCommand.js View on Github external
const updatedPackageJSON = name =>
  writePkg.sync.mock.calls
    .reduce((arr, args) => {
      if (args[1].name === name) {
        arr.push(args[1]);
      }
      return arr;
    }, [])
    .pop();
github lerna / lerna / test / NpmUtilities.js View on Github external
beforeEach(() => {
      stubExecOpts();
      ChildProcessUtilities.exec.mockImplementation(() => Promise.resolve());
      FileSystemUtilities.rename.mockImplementation((...args) => args.pop()());
      writePkg.mockImplementation(() => Promise.resolve());
    });
github xing / hops / packages / create-hops-app / lib / init.js View on Github external
.then(() => {
        deleteFiles(appRoot, [tarball, 'CHANGELOG.md', 'LICENSE.txt']);
        renameDotFiles(appRoot, ['_gitignore', '_npmrc']);

        writePkg(
          pathToPackageManifest,
          mergePackageManifest(
            readPkg(pathToPackageManifest),
            oldPackageManifest
          )
        );
        pm.installPackages([], null, options);

        console.log('Hooray \\o/');
        console.log('Your project has been successfully created.');
        console.log(
          `You should \`cd ${appName}\` to change into its directory and execute`,
          '`' + (pm.hasBeenInstalledViaYarn(options) ? 'yarn' : 'npm'),
          'start`',
          'to fire up a development server with hot module reloading.'
        );
github xing / hops / packages / create-hops-app / lib / create-app.js View on Github external
module.exports = function init(options, root) {
  const name = options.projectName;
  const appDir = path.join(root, name);

  validateName(name);
  createDirectory(appDir, name);
  writePkg(path.join(appDir, 'package.json'), {
    name: name,
    version: '1.0.0',
    private: true,
  });

  process.chdir(appDir);
  require('./init').init(root, name, options);
};
github asfktz / autodll-webpack-plugin / specs / helpers / integration / index.js View on Github external
change() {
      writePkg.sync(
        cwd,
        merge(originalPkg, {
          dependencies: merge(originalPkg.dependencies, {
            ___TEST_DEP___: (Math.random() * 10000000000).toFixed(),
          }),
        })
      );
    },
    restore() {

write-pkg

Write a package.json file

MIT
Latest version published 6 months ago

Package Health Score

58 / 100
Full package analysis