assets-manager
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -49,2 +49,6 @@ 'use strict'; | ||
var _chalk = require('chalk'); | ||
var _chalk2 = _interopRequireDefault(_chalk); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -125,4 +129,4 @@ | ||
for (var pkg in this.packages) { | ||
files = files.concat(this.packages[pkg].getFilesByType(type, options)); | ||
for (var pkg in this.installedPackages) { | ||
files = files.concat(this.installedPackages[pkg].getFilesByType(type, options)); | ||
} | ||
@@ -132,4 +136,4 @@ } else { | ||
for (var _pkg in this.packages) { | ||
var typedFiles = this.packages[_pkg].getTypedFiles(options); | ||
for (var _pkg in this.installedPackages) { | ||
var typedFiles = this.installedPackages[_pkg].getTypedFiles(options); | ||
for (var t in typedFiles) { | ||
@@ -156,2 +160,5 @@ if (t in files) { | ||
} | ||
if (!pkg.isInstalled()) { | ||
throw new Error('Package ' + name + ' is not installed'); | ||
} | ||
var dests = Object.assign(this.dests, pkg.getDests()); | ||
@@ -214,23 +221,36 @@ var typedFiles = pkg.getTypedFiles(); | ||
value: function copyPackage(name) { | ||
var _this2 = this; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var pkg = this.getPackage(name); | ||
return new Promise(function (resolve, reject) { | ||
var pkg = _this2.getPackage(name); | ||
if (pkg === null) { | ||
return new Promise(function (resolve, reject) { | ||
if (pkg === null) { | ||
reject(new Error('Package ' + name + ' is not exists')); | ||
}); | ||
} | ||
} | ||
options = Object.assign({ | ||
verbose: this.getConfigure('verbose'), | ||
override: this.getConfigure('override'), | ||
replaces: Object.assign(this.getConfigure('replaces'), pkg.options.replaces) | ||
}, options); | ||
if (!pkg.isInstalled()) { | ||
reject(new Error('Package ' + name + ' is not installed')); | ||
} | ||
var files = this.getPackageFileMapping(name); | ||
options = Object.assign({ | ||
verbose: _this2.getConfigure('verbose'), | ||
override: _this2.getConfigure('override'), | ||
log: console.log | ||
}, options); | ||
return _file2.default.copyFiles(files, Object.assign({ | ||
cwd: _configure2.default.get('cwd') | ||
}, options)); | ||
var log = options.verbose ? options.log : function () {}; | ||
if (options.verbose) { | ||
log(_chalk2.default.blue('Copying Package ') + name + ':'); | ||
} | ||
var files = _this2.getPackageFileMapping(name); | ||
_file2.default.copyFiles(files, Object.assign({ | ||
cwd: _configure2.default.get('cwd'), | ||
replaces: Object.assign(_this2.getConfigure('replaces'), pkg.options.replaces) | ||
}, options)).then(resolve).catch(reject); | ||
}); | ||
} | ||
@@ -251,26 +271,39 @@ }, { | ||
value: function cleanPackage(name) { | ||
var _this3 = this; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var pkg = this.getPackage(name); | ||
return new Promise(function (resolve, reject) { | ||
var pkg = _this3.getPackage(name); | ||
if (pkg === null) { | ||
return new Promise(function (resolve, reject) { | ||
if (pkg === null) { | ||
reject(new Error('Package ' + name + ' is not exists')); | ||
}); | ||
} | ||
} | ||
options = Object.assign({ | ||
verbose: this.getConfigure('verbose') | ||
}, options); | ||
if (!pkg.isInstalled()) { | ||
reject(new Error('Package ' + name + ' is not installed')); | ||
} | ||
var files = this.getPackageFileMapping(name); | ||
var destFiles = []; | ||
options = Object.assign({ | ||
verbose: _this3.getConfigure('verbose'), | ||
log: console.log | ||
}, options); | ||
files.forEach(function (file) { | ||
destFiles.push(file.dest); | ||
var log = options.verbose ? options.log : function () {}; | ||
if (options.verbose) { | ||
log(_chalk2.default.magenta('Clean Package ') + name + ":"); | ||
} | ||
var files = _this3.getPackageFileMapping(name); | ||
var destFiles = []; | ||
files.forEach(function (file) { | ||
destFiles.push(file.dest); | ||
}); | ||
_file2.default.cleanFiles(destFiles, Object.assign({ | ||
cwd: _configure2.default.get('cwd') | ||
}, options)).then(resolve).catch(reject); | ||
}); | ||
return _file2.default.cleanFiles(destFiles, Object.assign({ | ||
cwd: _configure2.default.get('cwd') | ||
}, options)); | ||
} | ||
@@ -300,4 +333,4 @@ }, { | ||
for (var pkg in this.packages) { | ||
packageInfo = this.packages[pkg].getInfo(); | ||
for (var pkg in this.installedPackages) { | ||
packageInfo = this.installedPackages[pkg].getInfo(); | ||
obj = {}; | ||
@@ -389,2 +422,3 @@ | ||
var packages = {}; | ||
var installedPackages = {}; | ||
@@ -409,2 +443,3 @@ for (var key in this.data.packages) { | ||
/* todo */ | ||
if (Object.hasOwnProperty.call(packages, name)) { | ||
@@ -419,5 +454,9 @@ if (Array.isArray(packages[name])) { | ||
} | ||
if (pkg.isInstalled()) { | ||
installedPackages[name] = pkg; | ||
} | ||
} | ||
this.packages = packages; | ||
this.installedPackages = installedPackages; | ||
} | ||
@@ -424,0 +463,0 @@ }, { |
@@ -58,3 +58,3 @@ 'use strict'; | ||
return null; | ||
return []; | ||
} | ||
@@ -61,0 +61,0 @@ }, { |
@@ -69,3 +69,3 @@ 'use strict'; | ||
var info = null; | ||
var info = {}; | ||
@@ -76,3 +76,3 @@ if (_file2.default.exists(infoPath)) { | ||
if (info && typeof key !== 'undefined') { | ||
if (typeof key !== 'undefined') { | ||
if (Object.hasOwnProperty.call(info, key)) { | ||
@@ -79,0 +79,0 @@ return info[key]; |
@@ -65,7 +65,7 @@ 'use strict'; | ||
if (!_file2.default.isDirectory(packagePath)) { | ||
return null; | ||
return {}; | ||
} | ||
var infoPath = _path2.default.join(packagePath, this.options.json); | ||
var info = null; | ||
var info = {}; | ||
@@ -80,3 +80,3 @@ if (_file2.default.exists(infoPath)) { | ||
if (info && typeof key !== 'undefined') { | ||
if (typeof key !== 'undefined') { | ||
if (Object.hasOwnProperty.call(info, key)) { | ||
@@ -83,0 +83,0 @@ return info[key]; |
@@ -56,3 +56,3 @@ 'use strict'; | ||
return null; | ||
return []; | ||
} | ||
@@ -63,3 +63,3 @@ }, { | ||
var infoPath = _path2.default.join(this.getPackagePath(packageName), this.options.json); | ||
var info = null; | ||
var info = {}; | ||
@@ -70,3 +70,3 @@ if (_file2.default.exists(infoPath)) { | ||
if (info && typeof key !== 'undefined') { | ||
if (typeof key !== 'undefined') { | ||
if (Object.hasOwnProperty.call(info, key)) { | ||
@@ -73,0 +73,0 @@ return info[key]; |
{ | ||
"name": "assets-manager", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Copy packages files based on manifest file", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/amazingSurge/assets-manager", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66878
1440