@shopify/slate-config
Advanced tools
Comparing version 1.0.0-alpha.19 to 1.0.0-alpha.20
@@ -1,5 +0,3 @@ | ||
const fs = require('fs'); | ||
const slateConfig = require('../index'); | ||
const schema = require('./fixtures/schema'); | ||
const slaterc = require('./fixtures/slaterc.json'); | ||
@@ -18,16 +16,10 @@ describe('.generate()', () => { | ||
test('with slaterc overrides', () => { | ||
const oldReadFileSync = fs.readFileSync; | ||
const mockSlateRc = require('./fixtures/slate.config.js'); | ||
fs.readFileSync = jest.fn(() => { | ||
return slaterc; | ||
}); | ||
expect(slateConfig.generate(schema)).toHaveProperty( | ||
expect(slateConfig.generate(schema, mockSlateRc)).toHaveProperty( | ||
schema.items[0].id, | ||
'override-value', | ||
); | ||
fs.readFileSync = oldReadFileSync; | ||
}); | ||
}); | ||
}); |
12
index.js
@@ -8,6 +8,6 @@ const path = require('path'); | ||
function getSlateRc(slatePath) { | ||
function getSlateConfig() { | ||
try { | ||
const json = fs.readFileSync(slatePath, 'utf8'); | ||
return typeof json === 'object' ? json : JSON.parse(json); | ||
const slateRcPath = resolveTheme('slate.config.js'); | ||
return require(slateRcPath); | ||
} catch (error) { | ||
@@ -18,5 +18,3 @@ return {}; | ||
function generate(schema) { | ||
const slateRcPath = resolveTheme('.slaterc'); | ||
const slaterc = getSlateRc(slateRcPath); | ||
function generate(schema, slaterc = getSlateConfig()) { | ||
const items = schema.items || []; | ||
@@ -57,3 +55,3 @@ const config = {}; | ||
resolveTheme, | ||
getSlateRc, | ||
getSlateConfig, | ||
}; |
{ | ||
"name": "@shopify/slate-config", | ||
"version": "1.0.0-alpha.19", | ||
"description": "Generate Slate config files", | ||
"version": "1.0.0-alpha.20", | ||
"description": "Generate configurations for Slate packages by applying values from slate.config.js to override default values", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/shopify/slate.git" | ||
}, | ||
"repository": "https://github.com/Shopify/slate/tree/1.x/packages/slate-config", | ||
"author": "Shopify Inc.", | ||
@@ -18,3 +12,3 @@ "license": "MIT", | ||
}, | ||
"homepage": "https://github.com/shopify/slate#readme" | ||
"homepage": "https://github.com/shopify/slate" | ||
} |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
5467
1
29
153
3