@shopify/slate-rc
Advanced tools
Comparing version 1.0.0-beta.7 to 1.0.0-beta.8
@@ -1,3 +0,5 @@ | ||
jest.mock('../slate-rc.config'); | ||
const SlateConfig = require('@shopify/slate-config'); | ||
jest.mock('../slate-rc.schema'); | ||
const MOCK_VALID_SLATE_RC = { | ||
@@ -16,5 +18,7 @@ uuid: '9a983jf94jk42', | ||
const mock = require('mock-fs'); | ||
const config = require('../slate-rc.config'); | ||
const config = new SlateConfig(require('../slate-rc.schema')); | ||
mock({[config.slateRcPath]: JSON.stringify(MOCK_VALID_SLATE_RC)}); | ||
mock({ | ||
[config.get('paths.slateRc')]: JSON.stringify(MOCK_VALID_SLATE_RC), | ||
}); | ||
@@ -27,6 +31,6 @@ expect(slateRc.get()).toMatchObject(MOCK_VALID_SLATE_RC); | ||
const SlateRcError = require('../slate-rc-error'); | ||
const config = require('../slate-rc.config'); | ||
const config = new SlateConfig(require('../slate-rc.schema')); | ||
const mock = require('mock-fs'); | ||
mock({[config.slateRcPath]: 'some invalid JSON'}); | ||
mock({[config.get('paths.slateRc')]: 'some invalid JSON'}); | ||
@@ -40,6 +44,6 @@ expect(() => { | ||
const slateRc = require('../index'); | ||
const config = require('../slate-rc.config'); | ||
const config = new SlateConfig(require('../slate-rc.schema')); | ||
const mock = require('mock-fs'); | ||
mock({[config.slateRcPath]: ''}); | ||
mock({[config.get('paths.slateRc')]: ''}); | ||
@@ -63,3 +67,3 @@ expect(slateRc.get()).toBe(null); | ||
const slateRc = require('../index'); | ||
const config = require('../slate-rc.config'); | ||
const config = new SlateConfig(require('../slate-rc.schema')); | ||
const mock = require('mock-fs'); | ||
@@ -72,3 +76,3 @@ const fs = require('fs'); | ||
expect(fs.existsSync(config.slateRcPath)).toBeTruthy(); | ||
expect(fs.existsSync(config.get('paths.slateRc'))).toBeTruthy(); | ||
expect(content.uuid).toBeDefined(); | ||
@@ -98,5 +102,5 @@ }); | ||
const mock = require('mock-fs'); | ||
const config = require('../slate-rc.config'); | ||
const config = new SlateConfig(require('../slate-rc.schema')); | ||
mock({[config.slateRcPath]: JSON.stringify(MOCK_VALID_SLATE_RC)}); | ||
mock({[config.get('paths.slateRc')]: JSON.stringify(MOCK_VALID_SLATE_RC)}); | ||
@@ -103,0 +107,0 @@ rc.update({someChange: 'value'}); |
19
index.js
const fs = require('fs'); | ||
const uuidGenerator = require('uuid/v4'); | ||
const config = require('./slate-rc.config'); | ||
const SlateConfig = require('@shopify/slate-config'); | ||
const config = new SlateConfig(require('./slate-rc.schema')); | ||
const SlateRcError = require('./slate-rc-error'); | ||
function get() { | ||
if (!fs.existsSync(config.slateRcPath)) { | ||
if (!fs.existsSync(config.get('paths.slateRc'))) { | ||
return null; | ||
} | ||
const buffer = fs.readFileSync(config.slateRcPath); | ||
const buffer = fs.readFileSync(config.get('paths.slateRc')); | ||
@@ -21,5 +22,5 @@ if (buffer.toString('utf8') === '') { | ||
throw new SlateRcError( | ||
`There was an error while JSON parsing ${ | ||
config.slateRcPath | ||
}. Please make sure file is valid JSON.`, | ||
`There was an error while JSON parsing ${config.get( | ||
'paths.slateRc', | ||
)}. Please make sure file is valid JSON.`, | ||
); | ||
@@ -30,3 +31,3 @@ } | ||
function generate() { | ||
if (fs.existsSync(config.slateRcPath)) { | ||
if (fs.existsSync(config.get('paths.slateRc'))) { | ||
throw new SlateRcError( | ||
@@ -41,3 +42,3 @@ '.slaterc file already exists. Use the update() method to update its values.', | ||
fs.writeFileSync(config.slateRcPath, JSON.stringify(content)); | ||
fs.writeFileSync(config.get('paths.slateRc'), JSON.stringify(content)); | ||
@@ -49,3 +50,3 @@ return content; | ||
const content = Object.assign({}, get(), updates); | ||
fs.writeFileSync(config.slateRcPath, JSON.stringify(content)); | ||
fs.writeFileSync(config.get('paths.slateRc'), JSON.stringify(content)); | ||
return content; | ||
@@ -52,0 +53,0 @@ } |
{ | ||
"name": "@shopify/slate-rc", | ||
"version": "1.0.0-beta.7", | ||
"version": "1.0.0-beta.8", | ||
"description": "Slate's global configuration manager. Generates, reads, and applies values to a global .slaterc file", | ||
@@ -14,4 +14,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@shopify/slate-config": "1.0.0-beta.7", | ||
"@shopify/slate-error": "1.0.0-beta.7", | ||
"@shopify/slate-config": "1.0.0-beta.8", | ||
"@shopify/slate-error": "1.0.0-beta.8", | ||
"fs-extra": "^5.0.0", | ||
@@ -18,0 +18,0 @@ "mock-fs": "^4.4.2", |
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
5542
140
+ Added@shopify/slate-config@1.0.0-beta.8(transitive)
+ Added@shopify/slate-error@1.0.0-beta.8(transitive)
- Removed@shopify/slate-config@1.0.0-beta.7(transitive)
- Removed@shopify/slate-error@1.0.0-beta.7(transitive)