diff --git a/spec/fixtures/packages/package-with-grammars/grammars/alittle.cson b/spec/fixtures/packages/package-with-grammars/grammars/alittle.cson deleted file mode 100644 index c72bea137..000000000 --- a/spec/fixtures/packages/package-with-grammars/grammars/alittle.cson +++ /dev/null @@ -1,12 +0,0 @@ -'fileTypes': ['alittle'] -'name': 'Alittle' -'scopeName': 'source.alittle' - -'patterns': [ - { - 'captures': - '0': - 'name': 'keyword.alittle' - 'match': 'alittle' - } -] diff --git a/spec/fixtures/packages/package-with-grammars/grammars/alot.cson b/spec/fixtures/packages/package-with-grammars/grammars/alot.cson deleted file mode 100644 index c8999a942..000000000 --- a/spec/fixtures/packages/package-with-grammars/grammars/alot.cson +++ /dev/null @@ -1,12 +0,0 @@ -'fileTypes': ['alot', 'foobizbang'] -'name': 'Alot' -'scopeName': 'source.alot' - -'patterns': [ - { - 'captures': - '0': - 'name': 'keyword.alot' - 'match': 'alot' - } -] diff --git a/spec/fixtures/packages/package-with-injection-selector/grammars/grammar.cson b/spec/fixtures/packages/package-with-injection-selector/grammars/grammar.cson deleted file mode 100644 index 3cee5379e..000000000 --- a/spec/fixtures/packages/package-with-injection-selector/grammars/grammar.cson +++ /dev/null @@ -1,4 +0,0 @@ -'name': 'test' -'scopeName': 'source.test' -'injectionSelector': 'comment' -'patterns': [{'include': 'source.sql'}] diff --git a/spec/fixtures/packages/package-with-keymaps-manifest/package.cson b/spec/fixtures/packages/package-with-keymaps-manifest/package.cson deleted file mode 100644 index e7bdccfa7..000000000 --- a/spec/fixtures/packages/package-with-keymaps-manifest/package.cson +++ /dev/null @@ -1 +0,0 @@ -keymaps: ["keymap-2", "keymap-1"] diff --git a/spec/fixtures/packages/package-with-keymaps-manifest/package.json b/spec/fixtures/packages/package-with-keymaps-manifest/package.json new file mode 100644 index 000000000..e1a4d416c --- /dev/null +++ b/spec/fixtures/packages/package-with-keymaps-manifest/package.json @@ -0,0 +1,3 @@ +{ + "keymaps": ["keymap-2", "keymap-1"] +} diff --git a/spec/fixtures/packages/package-with-main/package.cson b/spec/fixtures/packages/package-with-main/package.cson deleted file mode 100644 index a93a109c4..000000000 --- a/spec/fixtures/packages/package-with-main/package.cson +++ /dev/null @@ -1 +0,0 @@ -'main': 'main-module.coffee' \ No newline at end of file diff --git a/spec/fixtures/packages/package-with-main/package.json b/spec/fixtures/packages/package-with-main/package.json new file mode 100644 index 000000000..fc218060f --- /dev/null +++ b/spec/fixtures/packages/package-with-main/package.json @@ -0,0 +1,3 @@ +{ + "main": "main-module.coffee" +} diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson deleted file mode 100644 index f35a42726..000000000 --- a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson +++ /dev/null @@ -1,8 +0,0 @@ -'menu': [ - { 'label': 'Last' } -] - -'context-menu': - '.test-1': [ - {label: 'Menu item 1', command: 'command-1'} - ] diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.json b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.json new file mode 100644 index 000000000..81d7e470d --- /dev/null +++ b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.json @@ -0,0 +1,5 @@ +{ + "menu": [ + { "label": "Last" } + ] +} diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson deleted file mode 100644 index e67b879d1..000000000 --- a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson +++ /dev/null @@ -1,8 +0,0 @@ -'menu': [ - { 'label': 'Second to Last' } -] - -'context-menu': - '.test-1': [ - {label: 'Menu item 2', command: 'command-2'} - ] diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.json b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.json new file mode 100644 index 000000000..fb0c58e50 --- /dev/null +++ b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.json @@ -0,0 +1,5 @@ +{ + "menu": [ + { "label": "Second to Last" } + ] +} diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson deleted file mode 100644 index a93a864ab..000000000 --- a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson +++ /dev/null @@ -1,4 +0,0 @@ -'context-menu': - '.test-1': [ - {label: 'Menu item 3', command: 'command-3'} - ] diff --git a/spec/fixtures/packages/package-with-menus-manifest/package.cson b/spec/fixtures/packages/package-with-menus-manifest/package.cson deleted file mode 100644 index 1a3efbda3..000000000 --- a/spec/fixtures/packages/package-with-menus-manifest/package.cson +++ /dev/null @@ -1 +0,0 @@ -menus: ["menu-2", "menu-1"] diff --git a/spec/fixtures/packages/package-with-menus-manifest/package.json b/spec/fixtures/packages/package-with-menus-manifest/package.json new file mode 100644 index 000000000..59bf836f1 --- /dev/null +++ b/spec/fixtures/packages/package-with-menus-manifest/package.json @@ -0,0 +1,3 @@ +{ + "menus": ["menu-2", "menu-1"] +} diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-1.cson b/spec/fixtures/packages/package-with-menus/menus/menu-1.cson deleted file mode 100644 index 0c95f5972..000000000 --- a/spec/fixtures/packages/package-with-menus/menus/menu-1.cson +++ /dev/null @@ -1,8 +0,0 @@ -'menu': [ - {'label': 'Second to Last'} -] - -'context-menu': - '.test-1': [ - {label: 'Menu item 1', command: 'command-1'} - ] diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-1.json b/spec/fixtures/packages/package-with-menus/menus/menu-1.json new file mode 100644 index 000000000..81d7e470d --- /dev/null +++ b/spec/fixtures/packages/package-with-menus/menus/menu-1.json @@ -0,0 +1,5 @@ +{ + "menu": [ + { "label": "Last" } + ] +} diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-2.cson b/spec/fixtures/packages/package-with-menus/menus/menu-2.cson deleted file mode 100644 index 46c3fb9ef..000000000 --- a/spec/fixtures/packages/package-with-menus/menus/menu-2.cson +++ /dev/null @@ -1,8 +0,0 @@ -'menu': [ - { 'label': 'Last' } -] - -'context-menu': - '.test-1': [ - {label: 'Menu item 2', command: 'command-2'} - ] diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-2.json b/spec/fixtures/packages/package-with-menus/menus/menu-2.json new file mode 100644 index 000000000..fb0c58e50 --- /dev/null +++ b/spec/fixtures/packages/package-with-menus/menus/menu-2.json @@ -0,0 +1,5 @@ +{ + "menu": [ + { "label": "Second to Last" } + ] +} diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-3.cson b/spec/fixtures/packages/package-with-menus/menus/menu-3.cson deleted file mode 100644 index 445028db6..000000000 --- a/spec/fixtures/packages/package-with-menus/menus/menu-3.cson +++ /dev/null @@ -1,8 +0,0 @@ -'menu': [ - { 'label': 'Second to Last' } -] - -'context-menu': - '.test-1': [ - {label: 'Menu item 3', command: 'command-3'} - ] diff --git a/spec/fixtures/packages/package-with-models/package.cson b/spec/fixtures/packages/package-with-models/package.cson deleted file mode 100644 index a93a109c4..000000000 --- a/spec/fixtures/packages/package-with-models/package.cson +++ /dev/null @@ -1 +0,0 @@ -'main': 'main-module.coffee' \ No newline at end of file diff --git a/spec/fixtures/packages/package-with-models/package.json b/spec/fixtures/packages/package-with-models/package.json new file mode 100644 index 000000000..fc218060f --- /dev/null +++ b/spec/fixtures/packages/package-with-models/package.json @@ -0,0 +1,3 @@ +{ + "main": "main-module.coffee" +} diff --git a/spec/fixtures/packages/package-with-serialize-error/package.cson b/spec/fixtures/packages/package-with-serialize-error/package.cson deleted file mode 100644 index 300ce2fc0..000000000 --- a/spec/fixtures/packages/package-with-serialize-error/package.cson +++ /dev/null @@ -1 +0,0 @@ -'main': 'index.coffee' diff --git a/spec/fixtures/packages/package-with-serialize-error/package.json b/spec/fixtures/packages/package-with-serialize-error/package.json new file mode 100644 index 000000000..02503ebe4 --- /dev/null +++ b/spec/fixtures/packages/package-with-serialize-error/package.json @@ -0,0 +1,3 @@ +{ + "main": "index.coffee" +} diff --git a/spec/fixtures/packages/package-with-settings/settings/omg.cson b/spec/fixtures/packages/package-with-settings/settings/omg.cson deleted file mode 100644 index 4a3037963..000000000 --- a/spec/fixtures/packages/package-with-settings/settings/omg.cson +++ /dev/null @@ -1,3 +0,0 @@ -'.source.omg': - 'editor': - 'increaseIndentPattern': '^a' diff --git a/spec/fixtures/packages/package-with-style-sheets-manifest/package.cson b/spec/fixtures/packages/package-with-style-sheets-manifest/package.cson deleted file mode 100644 index 07c6082e5..000000000 --- a/spec/fixtures/packages/package-with-style-sheets-manifest/package.cson +++ /dev/null @@ -1 +0,0 @@ -styleSheets: ['2', '1'] diff --git a/spec/fixtures/packages/package-with-style-sheets-manifest/package.json b/spec/fixtures/packages/package-with-style-sheets-manifest/package.json new file mode 100644 index 000000000..89d283d36 --- /dev/null +++ b/spec/fixtures/packages/package-with-style-sheets-manifest/package.json @@ -0,0 +1,3 @@ +{ + "styleSheets": ["2", "1"] +} diff --git a/spec/fixtures/packages/package-with-stylesheets-manifest/package.cson b/spec/fixtures/packages/package-with-stylesheets-manifest/package.cson deleted file mode 100644 index 07c6082e5..000000000 --- a/spec/fixtures/packages/package-with-stylesheets-manifest/package.cson +++ /dev/null @@ -1 +0,0 @@ -styleSheets: ['2', '1'] diff --git a/spec/fixtures/packages/package-with-stylesheets-manifest/package.json b/spec/fixtures/packages/package-with-stylesheets-manifest/package.json new file mode 100644 index 000000000..89d283d36 --- /dev/null +++ b/spec/fixtures/packages/package-with-stylesheets-manifest/package.json @@ -0,0 +1,3 @@ +{ + "styleSheets": ["2", "1"] +} diff --git a/spec/fixtures/packages/package-without-module/package.cson b/spec/fixtures/packages/package-without-module/package.cson deleted file mode 100644 index c6e451934..000000000 --- a/spec/fixtures/packages/package-without-module/package.cson +++ /dev/null @@ -1 +0,0 @@ -"name": "perfect" diff --git a/spec/fixtures/packages/package-without-module/package.json b/spec/fixtures/packages/package-without-module/package.json new file mode 100644 index 000000000..522074741 --- /dev/null +++ b/spec/fixtures/packages/package-without-module/package.json @@ -0,0 +1,3 @@ +{ + "name": "perfect" +} diff --git a/spec/package-manager-spec.coffee b/spec/package-manager-spec.coffee index be35380d6..3438edfb8 100644 --- a/spec/package-manager-spec.coffee +++ b/spec/package-manager-spec.coffee @@ -267,8 +267,8 @@ describe "PackageManager", -> runs -> expect(NylasEnv.menu.template.length).toBe 2 - expect(NylasEnv.menu.template[0].label).toBe "Second to Last" - expect(NylasEnv.menu.template[1].label).toBe "Last" + expect(NylasEnv.menu.template[1].label).toBe "Second to Last" + expect(NylasEnv.menu.template[0].label).toBe "Last" describe "when the metadata contains a 'menus' manifest", -> it "loads only the menus specified by the manifest, in the specified order", -> diff --git a/src/package.coffee b/src/package.coffee index 74e265356..fc94d4f94 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -2,7 +2,6 @@ path = require 'path' _ = require 'underscore' async = require 'async' -CSON = require 'season' fs = require 'fs-plus' EmitterMixin = require('emissary').Emitter {Emitter, CompositeDisposable} = require 'event-kit' @@ -37,9 +36,10 @@ class Package if @isBundledPackagePath(packagePath) metadata = packagesCache[packageName]?.metadata unless metadata? - if metadataPath = CSON.resolve(path.join(packagePath, 'package')) + metadataPath = fs.resolve(path.join(packagePath, 'package.json')) + if fs.existsSync(metadataPath) try - metadata = CSON.readFileSync(metadataPath) + metadata = JSON.parse(fs.readFileSync(metadataPath)) catch error throw error unless ignoreErrors metadata ?= {} @@ -239,9 +239,9 @@ class Package if @bundledPackage and packagesCache[@name]? @menus = (["#{NylasEnv.packages.resourcePath}#{path.sep}#{menuPath}", menuObject] for menuPath, menuObject of packagesCache[@name].menus) else - @menus = @getMenuPaths().map (menuPath) -> [menuPath, CSON.readFileSync(menuPath) ? {}] + @menus = @getMenuPaths().map (menuPath) -> [menuPath, JSON.parse(fs.readFileSync(menuPath)) ? {}] catch e - console.error "Error reading keymaps for package '#{@name}': #{e.message}", e.stack + console.error "Error reading menus for package '#{@name}': #{e.message}", e.stack getKeymapPaths: -> keymapsDirPath = path.join(@path, 'keymaps') @@ -253,9 +253,9 @@ class Package getMenuPaths: -> menusDirPath = path.join(@path, 'menus') if @metadata.menus - @metadata.menus.map (name) -> fs.resolve(menusDirPath, name, ['json', 'cson', '']) + @metadata.menus.map (name) -> fs.resolve(menusDirPath, name, ['json', '']) else - fs.listSync(menusDirPath, ['cson', 'json']) + fs.listSync(menusDirPath, ['json']) loadStylesheets: -> @stylesheets = @getStylesheetPaths().map (stylesheetPath) ->