mirror of
https://github.com/atom/atom.git
synced 2026-02-15 00:55:14 -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:
@@ -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