azukiapp / azk

azk is a lightweight open source development environment orchestration tool. Instantly & safely run any environment on your local machine.
http://azk.io
Apache License 2.0
898 stars 63 forks source link

Adding module `Versions` to `utils` #618

Closed gullitmiranda closed 8 years ago

gullitmiranda commented 8 years ago

the module Versions is an abstraction above the semver.

Usage

import { Versions } from 'azk/utils';
Versions.parse('~> 1.0'        ); // => '1.0.0'
Versions.parse('1.0 1.2'       ); // => '1.0.0'
Versions.parse('1.0.1 or 1.2.3'); // => '1.0.1'

// https://regex101.com/r/jQ6eE8/3
var regex = /elixir[\s]*\:[\s]*\"(?:[~> ]*)?([0-9.]+)(?:(?:[or ]*)?([0-9.]+))?(?:.*)?\".*/gm;

Versions.match(regex, 'elixir: "~> 1.2",'           ); // => ['1.0.0', '1.2.0']
Versions.match(regex, 'elixir: "~> 1.0.1 or 1.2.3",'); // => ['1.0.1', '1.2.3']

Tests

azk gulp test --grep "Azk Utils Versions"
fearenales commented 8 years ago

LGTM