Code Monkey home page Code Monkey logo

json-bump's Introduction

json-bump

bumps the "version" entry for a JSON file

Version 1.0.0 note

With version 1.0.0, the node.js version returns a promise. Use async/await to ensure package.json gets properly written.

rationale

An easy to use component to bump the semver version of a JSON file. Includes both an exported package and a CLI.

installation

npm i json-bump

programmatic example

const bump = require('json-bump')

async function update() {
    await bump('package.json', { replace: '1.0.1' })
}
update()

command-line example

$ json-bump package.json
Updated package.json version from 0.1.2 to 0.1.3

$ json-bump data.json --minor
Updated data.json version from 1.0.5 to 1.1.0

$ json-bump

Usage: json-bump FILENAME [FLAGS]
Bumps the version in a json file using semver (MAJOR.MINOR.PATCH)

--replace=semver   this replaces the entire semver with the given string

--major=1          increment the major version (increments by 1 if flagged but not specified)
--minor=1          increment the minor version (increments by 1 if flagged but not specified)
--patch=1          increment the patch version (increments by 1 if flagged but not specified)
--entry=name       change entry updated (defaults is "version")
--spaces=4          number of spaces to format the .json file (set to 0 to remove spaces)

If no FLAGS are specified, increments PATCH by 1

API

async function version(filename, options)

bumps the "version" entry for a .json file

  • {string} filename
  • {object} [options] defaults to incrementing PATCH by 1 if no options are provided
  • {string="version"} [entry] name of entry to change
  • {number} [major] increment major by number (resetting MINOR and PATCH to 0)
  • {number} [minor] increment minor by number (resetting PATCH to 0)
  • {number} [patch] increment patch by number
  • {string} [replace] replace entry with this string
  • {number} [spaces=4] number of spaces to format the .json file (set to 0 to remove spaces)
  • returns: { updated: string, original: string, major: number, minor: number, patch: number }

license

MIT License (c) 2020 YOPEY YOPEY LLC by David Figatner

json-bump's People

Contributors

davidfig avatar

Stargazers

Kaan Gökdemir avatar  avatar

Watchers

 avatar James Cloos avatar

json-bump's Issues

--spaces does not seem to work

Hi,

I'm trying to update my package.json using two spaces only. I've tried the following commands:

json-bump package.json --spaces=2
json-bump --spaces=2 package.json

In both cases, indentation is made out of 4 spaces.

Am I doing it wrong, or is this a bug?

Node v8.16.0
npm 6.10.1
nvm 0.34.0
Linux 5.2.0 x64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.