Skip to content

Commit

Permalink
updates inline documents; #59
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Aug 10, 2014
1 parent d394dbb commit a94fac6
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions lib/command/install/installer.js
Expand Up @@ -8,7 +8,6 @@ var _ = require('underscore');
var request = require('request');
var fstream = require('fstream');
var tar = require('tar');
var stable = require('semver-stable');
var semver = require('semver-extra');

var EE = require('events').EventEmitter;
Expand Down Expand Up @@ -75,30 +74,46 @@ Installer.prototype._get_module_info = function(callback) {
var is_explicit_version = !!semver.valid(_version);
var version;

// # Convension
// - `cortex install <package> --save*` only in dev
// - `cortex install` in prereleases and production
// # 1. install from dependencies
// could occur in all situations

// # For a

// ## Case 1
// - 1.3.2 1.3.2-beta
// ## Case: the latest match is stable
// - dependencies: a: '^1.3.0'
// - prerelease: any
// cortex install -> install a@1.3.0
// - prerelease: any!
// - couch: 1.3.2, 1.3.2-beta
// -> install a@1.3.2

// ## Case 2
// - 1.3.2-alpha 1.3.2-beta
// ## Case: something is found
// - dependencies: a: '^1.3.0'
// - prerelease: alpha
// cortex install -> install a@1.3.0-alpha

// ## Case 3
// - couch:
// // normal
// - 1.3.2-alpha, 1.3.2-beta -> install a@1.3.0-alpha
// // the stable version is newer
// - 1.3.3, 1.3.2-alpha -> install a@1.3.3
// // the pr version is newer
// - 1.3.3-alpha, 1.3.2 -> install a@1.3.3-alpha

// ## Case 4: the specified pr is not found
// - 1.3.0-alpha 1.3.0-rc
// - dependencies: a: '^1.3.0'
// - prerelease: beta
// cortex install -> not found

// # 2. install --save
// Only available in dev

// ## install range
// - found stable -> ignore pr, install found
// - only found prerelease -> refuse install pr, warn, error
// - nothing found -> error

// ## recursive install --save -> install from dependencies

// ## install version
// - in versions: -> install
// - or: error

if (is_explicit_version) {
version = _version in versions
// cortex install hippo@1.2.3-beta
Expand All @@ -107,6 +122,12 @@ Installer.prototype._get_module_info = function(callback) {
: null;

} else {
var range = _version;
var matched = Object.keys(versions).filter(function (version) {
return semver.satisfies(version, range);
});


// stable version
version = stable.maxSatisfying(Object.keys(versions), _version);
if (!version) {
Expand Down

0 comments on commit a94fac6

Please sign in to comment.