Have ideas to improve npm?Join in the discussion! »

    package-json-utils

    1.1.1 • Public • Published

    package-json-utils

    TravisCI Status Coverage Status dependencies dev-dependencies Known Vulnerabilities npm version

    Read and update package.json files.

    Installation

    Simply run a install using your terminal and you're good to go!

    npm install --save package-json-utils

    If you're a cool kid using Yarn then simply just use yarn as you would

    yarn add package-json-utils

    Usage

    var pkg = require('package-json-utils');
     
    // Get all package json string
    var packageJson = pkg.getPackageJson();
     
    // Get project name
    // "name": "project name"
    var projectName = pkg.getProjectName();
     
    // Get project version
    // "version": "project version"
    var version = pkg.getVersion();
     
    // Get project description
    // "description": "project description"
    var description = pkg.getDescription();
     
    // Get project author (author -> name)
    // "author" : { "name" : "author name" }
    var author = pkg.getAuthor();
     
    // Get project email (author -> email)
    // "author" : { "email" : "author email" }
    var email = pkg.getEmail();
     
    // Get project github username (author -> url -> username)
    // "author" : { "url" : "https://github.com/username" }
    var username = pkg.getUsername();
     
    // Get project license
    // "license": "GPL-3.0"
    var license = pkg.getLicense();
     
    // Write all package json string
    pkg.setPackageJson(json);
     
    // Set project name
    // "name": "new name"
    pkg.setProjectName('new name');
     
    // Set project version
    // "version": "new version"
    pkg.setVersion('new version');
     
    // Set project description
    // "description": "new description"
    pkg.setDescription('new description');
     
    // Set project author (author -> name)
    // "author" : { "name" : "new name" }
    pkg.setAuthor('new name');
     
    // Set project email (author -> email)
    // "author" : { "email" : "new email" }
    pkg.setEmail('new email');
     
    // Set project license
    // "license": "new license"
    pkg.setLicense('new license');

    Keywords

    none

    Install

    npm i package-json-utils

    DownloadsWeekly Downloads

    26

    Version

    1.1.1

    License

    GPL-3.0

    Last publish

    Collaborators

    • avatar