Skip to content

Commit

Permalink
chore: remove async dev dep
Browse files Browse the repository at this point in the history
  • Loading branch information
ruyadorno committed Oct 10, 2020
1 parent db9c672 commit 30afb71
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 90 deletions.
27 changes: 7 additions & 20 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"validate-npm-package-license": "^3.0.1"
},
"devDependencies": {
"async": "^2.6.1",
"tap": "^14.10.8"
},
"files": [
Expand Down
56 changes: 23 additions & 33 deletions test/consistency.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
var tap = require("tap")
var normalize = require("../lib/normalize")
var path = require("path")
var fs = require("fs")
var async = require("async")
const t = require("tap")
const normalize = require("../lib/normalize")
const fs = require("fs")
const { promisify } = require("util")
const readFile = promisify(fs.readFile)
const readdir = promisify(fs.readdir)

var data, clonedData
var warn

tap.test("consistent normalization", function(t) {
path.resolve(__dirname, "./fixtures/read-package-json.json")
fs.readdir (__dirname + "/fixtures", function (err, entries) {
// entries = ['coffee-script.json'] // uncomment to limit to a specific file
verifyConsistency = function(entryName, next) {
warn = function(msg) {
// t.equal("",msg) // uncomment to have some kind of logging of warnings
}
filename = __dirname + "/fixtures/" + entryName
fs.readFile(filename, function(err, contents) {
if (err) return next(err)
data = JSON.parse(contents.toString())
normalize(data, warn)
clonedData = { ...data }
normalize(data, warn)
t.deepEqual(clonedData, data,
"Normalization of " + entryName + " is consistent.")
next(null)
}) // fs.readFile
} // verifyConsistency
async.forEach(entries, verifyConsistency, function(err) {
if (err) throw err
t.end()
})
}) // fs.readdir
}) // tap.test
t.test("consistent normalization", async t => {
const entries = await readdir(__dirname + "/fixtures")
const verifyConsistency = async (entryName) => {
const warn = () => null
const filename = __dirname + "/fixtures/" + entryName
const contents = await readFile(filename)

const data = JSON.parse(contents.toString())
normalize(data, warn)
const clonedData = { ...data }
normalize(data, warn)
t.deepEqual(clonedData, data,
"Normalization of " + entryName + " is consistent.")
}

return Promise.all(entries.map(i => verifyConsistency(i)))
})
63 changes: 27 additions & 36 deletions test/github-urls.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
var tap = require("tap")
var normalize = require("../lib/normalize")
var fs = require("fs")
var async = require("async")
const t = require("tap")
const normalize = require("../lib/normalize")
const fs = require("fs")
const { promisify } = require("util")
const readFile = promisify(fs.readFile)

var data
var warn

tap.test("consistent normalization", function(t) {
var entries = [
t.test("consistent normalization", async t => {
const entries = [
'read-package-json.json',
'http-server.json',
"movefile.json",
"node-module_exist.json"
]
var verifyConsistency = function(entryName, next) {
warn = function(msg) {
// t.equal("",msg) // uncomment to have some kind of logging of warnings
const verifyConsistency = async (entryName) => {
const warn = () => null
const filename = __dirname + "/fixtures/" + entryName
const contents = await readFile(filename)
const data = JSON.parse(contents.toString())
normalize(data, warn)
if(data.name == "node-module_exist") {
t.same(data.bugs.url, "https://gist.github.com/3135914")
}
var filename = __dirname + "/fixtures/" + entryName
fs.readFile(filename, function(err, contents) {
if (err) return next(err)
data = JSON.parse(contents.toString())
normalize(data, warn)
if(data.name == "node-module_exist") {
t.same(data.bugs.url, "https://gist.github.com/3135914")
}
if(data.name == "read-package-json") {
t.same(data.bugs.url, "https://github.com/isaacs/read-package-json/issues")
}
if(data.name == "http-server") {
t.same(data.bugs.url, "https://github.com/nodejitsu/http-server/issues")
}
if(data.name == "movefile") {
t.same(data.bugs.url, "https://github.com/yazgazan/movefile/issues")
}
next(null)
}) // fs.readFile
} // verifyConsistency
async.forEach(entries, verifyConsistency, function(err) {
if (err) throw err
t.end()
})
}) // tap.test
if(data.name == "read-package-json") {
t.same(data.bugs.url, "https://github.com/isaacs/read-package-json/issues")
}
if(data.name == "http-server") {
t.same(data.bugs.url, "https://github.com/nodejitsu/http-server/issues")
}
if(data.name == "movefile") {
t.same(data.bugs.url, "https://github.com/yazgazan/movefile/issues")
}
}
return Promise.all(entries.map(i => verifyConsistency(i)))
})

0 comments on commit 30afb71

Please sign in to comment.