bit-scope-client
Advanced tools
Comparing version 0.6.0 to 0.6.2
@@ -10,2 +10,7 @@ # Change Log | ||
## [0.6.2] - 2017-05-21 | ||
- add loadIfExists() to BitJson class so then it'll throw an error when bit.json is not there | ||
- importComponents returns a consistent object whether the save flag is set or not | ||
## [0.6.0] - 2017-05-15 | ||
@@ -12,0 +17,0 @@ |
@@ -40,2 +40,5 @@ 'use strict'; | ||
}; | ||
var readJson = function readJson(p) { | ||
return JSON.parse(_fsExtra2.default.readFileSync(p, 'utf8')); | ||
}; | ||
@@ -54,3 +57,3 @@ var BitJson = function () { | ||
this.dependencies = _ramda2.default.prop('dependencies', bitJson) || defaultBitJson.dependencies; | ||
this.packageDepndencies = _ramda2.default.prop('packageDepndencies', bitJson); | ||
this.packageDependencies = _ramda2.default.prop('packageDependencies', bitJson); | ||
this.dependencyMap = null; | ||
@@ -99,3 +102,3 @@ } | ||
dependencies: this.dependencies, | ||
packageDepndencies: this.packageDepndencies | ||
packageDependencies: this.packageDependencies | ||
}; | ||
@@ -128,2 +131,14 @@ } | ||
}], [{ | ||
key: 'loadIfExists', | ||
value: function loadIfExists(bitPath) { | ||
var bitJsonPath = composePath(bitPath); | ||
try { | ||
return new BitJson(readJson(bitJsonPath)); | ||
} catch (e) { | ||
if (e.code === 'ENOENT') throw e; | ||
throw new _invalidBitJson2.default(e, bitJsonPath); | ||
} | ||
} | ||
}, { | ||
key: 'load', | ||
@@ -133,9 +148,3 @@ value: function load(bitPath) { | ||
var readJson = function readJson(p) { | ||
return JSON.parse(_fsExtra2.default.readFileSync(p, 'utf8')); | ||
}; | ||
var composeBitJsonPath = function composeBitJsonPath(p) { | ||
return _path2.default.join(p, _constants.BIT_JSON_NAME); | ||
}; | ||
var bitJsonPath = composeBitJsonPath(bitPath); | ||
var bitJsonPath = composePath(bitPath); | ||
@@ -142,0 +151,0 @@ try { |
@@ -100,3 +100,5 @@ 'use strict'; | ||
return componentsP.then(function (components) { | ||
return _projectBitJson2.default.saveDependenciesIfNeeded(componentIds, components); | ||
return _projectBitJson2.default.saveDependenciesIfNeeded(componentIds, components).then(function () { | ||
return components; | ||
}); | ||
}); | ||
@@ -103,0 +105,0 @@ } |
{ | ||
"name": "bit-scope-client", | ||
"version": "0.6.0", | ||
"version": "0.6.2", | ||
"description": "A module for consuming bit components out of a remote scope", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -11,2 +11,3 @@ // @flow | ||
const composePath = p => path.join(p, BIT_JSON_NAME); | ||
const readJson = p => JSON.parse(fs.readFileSync(p, 'utf8')); | ||
@@ -20,3 +21,3 @@ class BitJson { | ||
dependencies: ?{[string]: string}; | ||
packageDepndencies: ?{[string]: string}; | ||
packageDependencies: ?{[string]: string}; | ||
dependencyMap: ?DependencyMap; | ||
@@ -31,3 +32,3 @@ | ||
this.dependencies = R.prop('dependencies', bitJson) || defaultBitJson.dependencies; | ||
this.packageDepndencies = R.prop('packageDepndencies', bitJson); | ||
this.packageDependencies = R.prop('packageDependencies', bitJson); | ||
this.dependencyMap = null; | ||
@@ -66,3 +67,3 @@ } | ||
dependencies: this.dependencies, | ||
packageDepndencies: this.packageDepndencies, | ||
packageDependencies: this.packageDependencies, | ||
}; | ||
@@ -93,6 +94,15 @@ } | ||
static loadIfExists(bitPath: string): ?BitJson { | ||
const bitJsonPath = composePath(bitPath); | ||
try { | ||
return new BitJson(readJson(bitJsonPath)); | ||
} catch (e) { | ||
if (e.code === 'ENOENT') throw e; | ||
throw new InvalidBitJsonException(e, bitJsonPath); | ||
} | ||
} | ||
static load(bitPath: string, defaultBitJson?: Object = {}): ?BitJson { | ||
const readJson = p => JSON.parse(fs.readFileSync(p, 'utf8')); | ||
const composeBitJsonPath = p => path.join(p, BIT_JSON_NAME); | ||
const bitJsonPath = composeBitJsonPath(bitPath); | ||
const bitJsonPath = composePath(bitPath); | ||
@@ -99,0 +109,0 @@ try { |
@@ -65,3 +65,3 @@ /* @flow */ | ||
return componentsP.then(components => projectBitJson.saveDependenciesIfNeeded(componentIds, | ||
components)); | ||
components).then(() => components)); | ||
} | ||
@@ -68,0 +68,0 @@ return componentsP; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
545392
279
9013