Skip to content

Commit

Permalink
support upgrading to latest version of metalsmith; resolve metalsmith…
Browse files Browse the repository at this point in the history
  • Loading branch information
exortech committed Jul 25, 2022
1 parent 99b41aa commit 14ea22e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
13 changes: 3 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ var _multimatch = require("multimatch");

var _multimatch2 = _interopRequireDefault(_multimatch);

var _unyield = require("unyield");

var _unyield2 = _interopRequireDefault(_unyield);

var _metalsmithFilenames = require("metalsmith-filenames");

var _metalsmithFilenames2 = _interopRequireDefault(_metalsmithFilenames);
Expand Down Expand Up @@ -200,19 +196,16 @@ function buildFiles(metalsmith, paths, livereload, options, previousFilesMap) {
}

function buildPattern(metalsmith, patterns, livereload, options, previousFilesMap) {
(0, _unyield2["default"])(metalsmith.read())(function (err, files) {
if (err) {
options.log(_chalk2["default"].red(nok + " " + err));
return;
}

metalsmith.read().then(function (files) {
var filesToUpdate = {};
(0, _multimatch2["default"])(Object.keys(files), patterns).forEach(function (path) {
return filesToUpdate[path] = files[path];
});
var nbOfFiles = Object.keys(filesToUpdate).length;
options.log(_chalk2["default"].gray("- Updating " + nbOfFiles + " file" + (nbOfFiles > 1 ? "s" : "") + "..."));
runAndUpdate(metalsmith, filesToUpdate, livereload, options, previousFilesMap);
})["catch"](function (err) {
return options.log(_chalk2["default"].red(nok + " " + err));
});
}

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
"gaze": "^1.0.0",
"metalsmith-filenames": "^1.0.0",
"multimatch": "^4.0.0",
"tiny-lr": "2.0.0",
"unyield": "0.0.1"
"tiny-lr": "2.0.0"
},
"devDependencies": {
"babel": "^5.1.13",
"babel-eslint": "^3.0.1",
"babel-tape-runner": "^1.1.0",
"eslint": "^0.20.0",
"metalsmith": "^1.7.0",
"metalsmith": "2.5.0",
"mkdirp": "1.0.4",
"npmpub": "^3.1.0",
"rimraf": "3.0.2",
Expand Down
10 changes: 2 additions & 8 deletions src/index.es
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import async from "async"
import gaze from "gaze"
import color from "chalk"
import multimatch from "multimatch"
import unyield from "unyield"
import metalsmithFilenames from "metalsmith-filenames"

import livereloadServer from "./livereload"
Expand Down Expand Up @@ -176,18 +175,13 @@ function buildFiles(metalsmith, paths, livereload, options, previousFilesMap) {
}

function buildPattern(metalsmith, patterns, livereload, options, previousFilesMap) {
unyield(metalsmith.read())((err, files) => {
if (err) {
options.log(color.red(`${nok} ${err}`))
return
}

metalsmith.read().then(files => {
const filesToUpdate = {}
multimatch(Object.keys(files), patterns).forEach(path => filesToUpdate[path] = files[path])
const nbOfFiles = Object.keys(filesToUpdate).length
options.log(color.gray(`- Updating ${nbOfFiles} file${nbOfFiles > 1 ? "s" : ""}...`))
runAndUpdate(metalsmith, filesToUpdate, livereload, options, previousFilesMap)
})
}).catch(err => options.log(color.red(`${nok} ${err}`)))
}

export default function(options) {
Expand Down

0 comments on commit 14ea22e

Please sign in to comment.