From 97ad2f30e028eb24320f86390aadb3a4b8bd09d2 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Mon, 4 May 2015 15:04:03 -0700 Subject: [PATCH] normalize all of package.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use different module, catch throws, and still remove the ‘git’ prefix from urls. --- package.json | 2 +- src/package.coffee | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 36ebaa55a..689050b05 100644 --- a/package.json +++ b/package.json @@ -38,13 +38,13 @@ "fuzzaldrin": "^2.1", "git-utils": "^3.0.0", "grim": "1.4.0", - "hosted-git-info": "^2.1.2", "jasmine-json": "~0.0", "jasmine-tagged": "^1.1.4", "jquery": "^2.1.1", "less-cache": "0.22", "marked": "^0.3.3", "mixto": "^1", + "normalize-package-data": "^2.0.0", "nslog": "^2.0.0", "oniguruma": "^4.1", "optimist": "0.4.0", diff --git a/src/package.coffee b/src/package.coffee index 05be6c79f..473b5dc33 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -1,5 +1,5 @@ path = require 'path' -hostedGitInfo = require 'hosted-git-info' +normalizePackageData = require 'normalize-package-data' _ = require 'underscore-plus' async = require 'async' @@ -27,15 +27,8 @@ class Package @normalizeMetadata: (metadata) -> if typeof metadata.repository is 'string' - metadata.repository = - type: 'git' - url: metadata.repository - - repoUrl = metadata.repository?.url - if repoUrl - info = hostedGitInfo.fromUrl(repoUrl) - if info.getDefaultRepresentation() is 'shortcut' - metadata.repository.url = info.https().replace(/^git\+/, '') + normalizePackageData(metadata) + metadata.repository.url = metadata.repository.url.replace(/^git\+/, '') @loadMetadata: (packagePath, ignoreErrors=false) -> packageName = path.basename(packagePath) @@ -45,12 +38,12 @@ class Package if metadataPath = CSON.resolve(path.join(packagePath, 'package')) try metadata = CSON.readFileSync(metadataPath) + @normalizeMetadata(metadata) catch error throw error unless ignoreErrors metadata ?= {} metadata.name = packageName - @normalizeMetadata(metadata) if includeDeprecatedAPIs and metadata.stylesheetMain? deprecate("Use the `mainStyleSheet` key instead of `stylesheetMain` in the `package.json` of `#{packageName}`", {packageName})