29 lines
867 B
JavaScript
Raw Normal View History

let fs = require('../core/fs.js');
2018-04-20 17:17:49 -04:00
let PluginManager = require('live-plugin-manager').PluginManager;
class Npm {
constructor(options) {
this.logger = options.logger;
}
2018-04-20 19:52:51 -04:00
getPackageVersion(packageName, version, callback) {
2018-04-20 17:17:49 -04:00
let packageDirectory = './.embark/versions/' + packageName + '/' + version + '/';
let manager = new PluginManager({pluginsPath: packageDirectory});
if (fs.existsSync(packageDirectory + packageName)) {
return callback(null, packageDirectory + packageName);
}
2018-04-20 17:17:49 -04:00
this.logger.info("downloading " + packageName + " " + version + "....");
2018-05-08 17:49:46 -04:00
this.logger.info(__("downloading {{packageName}} {{version}}....", {packageName: packageName, version: version}));
2018-04-20 17:17:49 -04:00
manager.install(packageName, version).then((result) => {
2018-04-20 19:52:51 -04:00
callback(null , result.location);
}).catch(callback);
}
}
module.exports = Npm;