normalize-package-data
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -337,3 +337,3 @@ var semver = require("semver") | ||
function depObjectify (deps) { | ||
function depObjectify (deps, type, warn) { | ||
if (!deps) return {} | ||
@@ -344,2 +344,3 @@ if (typeof deps === "string") { | ||
if (!Array.isArray(deps)) return deps | ||
warn("specifying " + type + " as array is deprecated") | ||
var o = {} | ||
@@ -362,3 +363,3 @@ deps.filter(function (d) { | ||
if (!data[type]) return; | ||
data[type] = depObjectify(data[type]) | ||
data[type] = depObjectify(data[type], type, warn) | ||
}) | ||
@@ -365,0 +366,0 @@ } |
{ | ||
"name": "normalize-package-data", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"author": "Meryn Stol <merynstol@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Normalizes data that can be found in package.json files.", |
@@ -173,2 +173,19 @@ var tap = require("tap") | ||
tap.test("deprecation warning for array in dependencies fields", function(t) { | ||
var a | ||
var warnings = [] | ||
function warn(w) { | ||
warnings.push(w) | ||
} | ||
normalize(a={ | ||
dependencies: [], | ||
devDependencies: [], | ||
optionalDependencies: [] | ||
}, warn) | ||
t.ok(~warnings.indexOf("specifying dependencies as array is deprecated"), "deprecation warning") | ||
t.ok(~warnings.indexOf("specifying devDependencies as array is deprecated"), "deprecation warning") | ||
t.ok(~warnings.indexOf("specifying optionalDependencies as array is deprecated"), "deprecation warning") | ||
t.end() | ||
}) | ||
tap.test('no new globals', function(t) { | ||
@@ -175,0 +192,0 @@ t.same(Object.keys(global), globals) |
46925
1271