mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Normalize repository short urls
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
"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",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
path = require 'path'
|
||||
hostedGitInfo = require 'hosted-git-info'
|
||||
|
||||
_ = require 'underscore-plus'
|
||||
async = require 'async'
|
||||
@@ -24,6 +25,20 @@ class Package
|
||||
@resourcePathWithTrailingSlash ?= "#{atom.packages.resourcePath}#{path.sep}"
|
||||
packagePath?.startsWith(@resourcePathWithTrailingSlash)
|
||||
|
||||
@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\+/, '')
|
||||
else
|
||||
metadata.repository.url = info.toString()
|
||||
|
||||
@loadMetadata: (packagePath, ignoreErrors=false) ->
|
||||
packageName = path.basename(packagePath)
|
||||
if @isBundledPackagePath(packagePath)
|
||||
@@ -34,8 +49,10 @@ class Package
|
||||
metadata = CSON.readFileSync(metadataPath)
|
||||
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