bulma/docs/_scripts/plugins/01-read-initial-variables.js

31 lines
646 B
JavaScript
Raw Normal View History

2018-06-16 17:26:55 +00:00
module.exports = plugin;
const utils = require('./utils');
function plugin() {
return (files, metalsmith, done) => {
setImmediate(done);
Object.keys(files).forEach(file_path => {
const {file_name, lines} = utils.getLines(files, file_path);
2018-06-16 19:47:52 +00:00
let variables = {
by_name: {},
list: [],
file_path,
};
2018-06-16 17:26:55 +00:00
lines.forEach(line => {
const variable = utils.parseLine(line);
if (variable != false) {
variables.by_name[variable.name] = variable;
2018-06-16 18:01:35 +00:00
variables.list.push(variable.name);
2018-06-16 17:26:55 +00:00
}
});
2018-06-16 18:01:35 +00:00
2018-06-16 18:58:58 +00:00
utils.writeFile(file_path, variables);
});
2018-06-16 17:26:55 +00:00
};
}