Skip to content

Commit

Permalink
Build: remove async and spawnback dependencies
Browse files Browse the repository at this point in the history
Use async-await, for-of, and cp.spawn directly.
  • Loading branch information
Krinkle committed Nov 12, 2023
1 parent 8f769df commit b51c322
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 222 deletions.
7 changes: 7 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

module.exports = function( grunt ) {
grunt.initConfig( {
xmllint: {
all: [
"fixture/entries/**",
"entries2html.xsl"
]
},
"build-posts": {
page: "fixture/pages/**"
},
Expand All @@ -21,5 +27,6 @@ module.exports = function( grunt ) {

grunt.loadTasks( "tasks" );

grunt.registerTask( "lint", [ "xmllint" ] );
grunt.registerTask( "build", [ "build-posts", "build-resources", "build-xml-entries" ] );
};
21 changes: 5 additions & 16 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";

const fs = require( "fs" );
const async = require( "async" );
const marked = require( "marked" );

function htmlEscape( text ) {
Expand Down Expand Up @@ -69,23 +68,13 @@ function parseMarkdown( src, options ) {
return marked.parser( tokens );
}

function eachFile( files, stepFn, complete ) {
var count = 0;

async.forEachSeries( files, function( fileName, fileDone ) {
async function eachFile( files, stepFn ) {
for ( const fileName of files ) {
if ( !fs.statSync( fileName ).isFile() ) {
return fileDone();
}

count++;
stepFn( fileName, fileDone );
}, function( error ) {
if ( error ) {
return complete( error );
continue;
}

complete( null, count );
} );
await stepFn( fileName );
}
}

exports.htmlEscape = htmlEscape;
Expand Down
12 changes: 0 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@
}
],
"dependencies": {
"async": "^3.2.0",
"cheerio": "^1.0.0-rc.12",
"grunt-check-modules": "^1.1.0",
"gilded-wordpress": "1.0.6",
"he": "^1.2.0",
"highlight.js": "^10.7.2",
"marked": "^4.0.0",
"spawnback": "^1.0.1",
"which": "^4.0.0",
"wordpress": "^1.4.1"
},
"scripts": {
"test": "eslint . && qunit test/*.js",
"lint-example": "grunt lint",
"build-example": "grunt build"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit b51c322

Please sign in to comment.