GithubHelp home page GithubHelp logo

semver-truncate's Introduction

semver-truncate

Truncate a semver version: 1.2.31.2.0

Install

$ npm install semver-truncate

Usage

import semverTruncate from 'semver-truncate';

semverTruncate('1.2.3-foo', 'patch');
//=> '1.2.3'

semverTruncate('1.2.3', 'minor');
//=> '1.2.0'

semverTruncate('1.2.3', 'major');
//=> '1.0.0'

API

truncateSemver(version, type)

version

Type: string

Semver version.

type

Type: 'patch' | 'minor' | 'major'

Version type to truncate to.

Related

  • latest-semver - Get the latest stable semver version from an array of versions
  • to-semver - Get an array of valid, sorted, and cleaned semver versions from an array of strings
  • semver-regex - Regular expression for matching semver versions
  • semver-diff - Get the diff type of two semver versions: 0.0.1 0.0.2patch

semver-truncate's People

Contributors

bendingbender avatar richienb avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

semver-truncate's Issues

"7.0.8-0ubuntu0.16.04.2" version raise error "TypeError: Cannot set property 'build' of null"

This version 7.0.8-0ubuntu0.16.04.2 is of PHP installed on my system currently, and I am using a library gulp-connect-php for my PHP work. Actually, this library has a dependency on library bin-version-check which depends on this library.

gulp-connect-php Line uses bin-version-check Line to check the PHP version and, then bin-version-check retrieve system PHP version and use semverTruncate().

On my system, PHP version is 7.0.8-0ubuntu0.16.04.2. So, this library raises an error.

/**********/node_modules/semver-truncate/index.js:11
version.build = '';
                  ^

TypeError: Cannot set property 'build' of null

TestCase:- semverTruncate("7.0.8-0ubuntu0.16.04.2", "patch") to create this error.

Please bump major version when dropping support for older node.js versions

Hello, in Your recent commit You started to use string templates which were introduced AFAIR in node v4.
While doing so You only bumped patch version which results in breaking packages which use Your module for people using node 0.12.

Example when trying to install flow-bin:

[16:41:34]> flow-bin@0.23.0 postinstall /ephemeral/teamcity/euca-10-254-205-85.eucalyptus.internal-01/work/946aa8e38ea48cb1/src/node_modules/@my_module/builder/node_modules/flow-bin
[16:41:34]> node lib/install.js
[16:41:34]
[16:41:34]/ephemeral/teamcity/euca-10-254-205-85.eucalyptus.internal-01/work/946aa8e38ea48cb1/src/node_modules/@my_module/builder/node_modules/flow-bin/node_modules/bin-wrapper/node_modules/bin-version-check/node_modules/semver-truncate/index.js:12
[16:41:34]      throw new Error(`Version ${version} is not valid semver`);
[16:41:34]                      ^
[16:41:34]SyntaxError: Unexpected token ILLEGAL
[16:41:34]    at exports.runInThisContext (vm.js:73:16)
[16:41:34]    at Module._compile (module.js:443:25)
[16:41:34]    at Object.Module._extensions..js (module.js:478:10)
[16:41:34]    at Module.load (module.js:355:32)
[16:41:34]    at Function.Module._load (module.js:310:12)
[16:41:34]    at Module.require (module.js:365:17)
[16:41:34]    at require (module.js:384:17)
[16:41:34]    at Object.<anonymous> (/ephemeral/teamcity/euca-10-254-205-85.eucalyptus.internal-01/work/946aa8e38ea48cb1/src/node_modules/@my_module/builder/node_modules/flow-bin/node_modules/bin-wrapper/node_modules/bin-version-check/index.js:4:22)
[16:41:34]    at Module._compile (module.js:460:26)
[16:41:34]    at Object.Module._extensions..js (module.js:478:10)

Can You please publish version 1.1.2 without string templates and bump major version for future development/releases which drops support for older node.js versions?

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.