1234567891011121314151617181920212223242526272829 |
- module.exports = plugin;
- const utils = require('./utils');
- function plugin() {
- let variables = {
- by_name: {},
- list: [],
- };
- return (files, metalsmith, done) => {
- setImmediate(done);
- Object.keys(files).forEach(file_path => {
- const {file_name, lines} = utils.getLines(files, file_path);
- lines.forEach(line => {
- const variable = utils.parseLine(line);
- if (variable != false) {
- variables.by_name[variable.name] = variable;
- variables.list.push(variable.name);
- }
- });
- utils.writeFile(file_path, variables);
- });
- };
- }
|