-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemver.js
73 lines (61 loc) · 1.55 KB
/
semver.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*!
* limon <https://github.com/limonjs/limon>
*
* Copyright (c) 2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
/* eslint-disable */
'use strict'
var lazy = require('../utils')
var limon = require('../index')
var semver = require('semver')
var plugins = require('./plugins')
/**
* Tokenize semver
*/
limon
.use(plugins.matcher())
.use(plugins.parseToken())
.use(plugins.semver())
var tokens = limon.tokenize('>= 12.617.33453455-bAB-Cuild+4.57 < 8.9.0')
console.log(tokens)
// console.log(semver.parse('12.617.33453455-bAB-Cuild+4.57'))
/**
* Semver parser
*/
// var res = {}
// res.raw = ''
// res.major = ''
// res.minor = ''
// res.patch = ''
// res.prerelease = []
// res.build = []
// res.version = ''
// var state = {space: 0, spaces: 0, dash: 0, dashes: 0, plus: 0, pluses: 0}
// var temp = ''
// var len = tokens.length
// var i = 0
// while (i < len) {
// var token = limon.parseToken(i++)
// delete token.next
// temp += token.value
// if (token.type === 'space') {
// state.space = token.start
// state.spaces++
// }
// if (token.type !== 'symbol' && token.type !== 'space') {
// if (token.start > state.space && state.spaces <= 1) {
// if (token.type === 'dash') {
// state.dash = token.start
// state.dashes++
// }
// if (state.dashes < 1) {
// // clean version: x.y.z
// // console.log('actual', token)
// }
// console.log(token)
// console.log(state)
// }
// }
// }
// console.log(res)