Files
bower/lib/commands/install.js
Andre Cruz fd31f247a6 Unit of work implementation.
A unit of work is a simple storage with write lock/unlock.
The manager/package now share a unit of work instance.
The unit of work is used to prevent shared dependencies from being cloned/copied "at the same time" fixing issue #81.
The prune and version resolving algorithm was also not correct. It now resolves versions correctly, fixing issue #57.

- Fix I/O errors caused by copying/clone repos simultaneously to the same dest.
- Optimize the clone/copy step by avoiding it if the last resolved resource is the same.
- Fix failing test (at least on my windows machine)
- Add some more tests
- Fix CS.
2012-10-11 13:40:54 +01:00

48 lines
1.4 KiB
JavaScript

// ==========================================
// BOWER: Install API
// ==========================================
// Copyright 2012 Twitter, Inc
// Licensed under The MIT License
// http://opensource.org/licenses/MIT
// ==========================================
// 1. Recursively resolve dependencies
// 2. Intelligently work out which deps to
// use (versioning)
// 3. Throw if deps conflict
// ==========================================
var Emitter = require('events').EventEmitter;
var async = require('async');
var nopt = require('nopt');
var Manager = require('../core/manager');
var save = require('../util/save');
var list = require('./list');
var help = require('./help');
var optionTypes = { help: Boolean };
var shorthand = { 'h': ['--help'], 'S': ['--save'] };
module.exports = function (paths, options) {
var emitter = new Emitter;
var manager = new Manager(paths)
if (options && options.save) save(emitter, manager, paths);
manager
.on('data' , emitter.emit.bind(emitter, 'data'))
.on('error' , emitter.emit.bind(emitter, 'error'))
.on('resolve' , emitter.emit.bind(emitter, 'end'))
.resolve();
return emitter;
};
module.exports.line = function (argv) {
var options = nopt(optionTypes, shorthand, argv);
var paths = options.argv.remain.slice(1);
if (options.help) return help('install');
return module.exports(paths, options);
};