This repository has been archived by the owner on Oct 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ddbeck/make-descriptions-requirable
Make it possible to require short-descriptions
- Loading branch information
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const extend = require('extend'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
function walk(directory, callback) { | ||
fs.readdirSync(directory).forEach((filename) => { | ||
const filepath = path.join(directory, filename); | ||
|
||
if (fs.statSync(filepath).isDirectory()) { | ||
walk(filepath, callback); | ||
} | ||
callback(filepath); | ||
}); | ||
} | ||
|
||
function collectJSON(directory) { | ||
const filepaths = []; | ||
walk(directory, (fp) => { | ||
if (path.extname(fp) === '.json') { | ||
filepaths.push(fp); | ||
} | ||
}); | ||
return filepaths; | ||
} | ||
|
||
function loadJSON() { | ||
const jsons = collectJSON(path.resolve(__dirname, './descriptions')); | ||
const finalObj = {}; | ||
|
||
jsons.forEach((json) => { | ||
const nextObj = JSON.parse(fs.readFileSync(json, 'utf8')); | ||
extend(true, finalObj, nextObj); | ||
}); | ||
return finalObj; | ||
} | ||
|
||
module.exports = loadJSON(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* eslint-disable no-underscore-dangle */ | ||
const assert = require('assert'); | ||
|
||
const descriptions = require('..'); | ||
|
||
// Make sure the data is importable and does something vaguely useful | ||
assert(typeof descriptions.css.properties.opacity.__short_description === 'string'); | ||
assert(descriptions.css.properties.opacity.__short_description.length > 0); |