mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
normalize all of package.json
use different module, catch throws, and still remove the ‘git’ prefix from urls.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user