Cannot create add commands to package sub menu


#1

Hi, I am developing a package for Atom and I am trying to add a second command to its menu, however I am getting the error below whenever I try to activate my package:

[Enter steps to reproduce:]

1. ...
2. ...

**Atom**: 1.14.3 x64
**Electron**: 1.3.13
**OS**: Microsoft Windows 10 Home Single Language
**Thrown From**: [srt-helper](https://github.com/komyg/srt-helper) package 0.0.0


### Stack Trace

Failed to load the srt-helper package

```
At Unexpected token { in JSON at position 377

SyntaxError: Unexpected token { in JSON at position 377
    at Object.parse (native)
    at parseObject (/app.asar/node_modules/season/lib/cson.js:54:19)
    at parseContentsSync (/app.asar/node_modules/season/lib/cson.js:68:16)
    at Object.readFileSync (/app.asar/node_modules/season/lib/cson.js:170:14)
    at /app.asar/src/package.js:463:42
    at Array.map (native)
    at Package.module.exports.Package.loadMenus (/app.asar/src/package.js:461:42)
    at /app.asar/src/package.js:115:19
    at Package.module.exports.Package.measure (/app.asar/src/package.js:96:15)
    at Package.module.exports.Package.load (/app.asar/src/package.js:110:12)
    at PackageManager.module.exports.PackageManager.loadPackage (/app.asar/src/package-manager.js:468:14)
    at /app.asar/src/package-manager.js:412:19
    at Config.module.exports.Config.transact (/app.asar/src/config.js:312:16)
    at PackageManager.module.exports.PackageManager.loadPackages (/app.asar/src/package-manager.js:407:19)
    at /app.asar/src/atom-environment.js:794:28
```

### Commands

```
```

### Non-Core Packages

```
atom-typescript 10.1.13 
linter 1.11.21 
srt-helper 0.0.0 
```

The problem happens on the menus->my-package.json file (below):

{
  "context-menu": {
    "atom-text-editor": [
      {
        "label": "Srt Copy Paste",
        "command": "srt-helper:srtCopyPaste"
      }
    ]
  },
  "menu": [
    {
      "label": "Packages",
      "submenu": [
        {
          "label": "Srt Helper",
          "submenu": [
            { "label": "Srt Copy Paste", "command": "srt-helper:srtCopyPaste" }
            { "label": "Choose destination editor",	"command": "srt-helper:srtChooseDestEditor"	}
          ]
        }
      ]
    }
  ]
}

The only thing that I did was add the following line: { "label": "Choose destination editor", "command": "srt-helper:srtChooseDestEditor" }. Whenever I remove it, the package loads correctly, so I am not sure what is wrong here, because I don’t see a missing β€˜{’.

Note, I aso changed my package.json like this:

{
  "name": "srt-helper",
  "main": "./lib/srt-helper",
  "version": "0.0.0",
  "description": "A short description of your package",
  "keywords": [
  ],
  "activationCommands": {
    "atom-workspace": "srt-helper:srtCopyPaste",
	"atom-workspace": "srt-helper:srtChooseDestEditor"
  },
  "repository": "https://github.com/",
  "license": "MIT",
  "engines": {
    "atom": ">=1.0.0 <2.0.0"
  },
  "dependencies": {
	  "jquery": "^2.1.4"
  }
}

And registered the functions in the package activation:

    activate(state)
	{

	    // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
	    this.subscriptions = new CompositeDisposable();

	    // Register command that toggles this view
	    this.subscriptions.add(atom.commands.add('atom-workspace', {
	      'srt-helper:srtCopyPaste': () => this.srtCopyPaste()
	    }));
		this.subscriptions.add(atom.commands.add('atom-workspace', {
	      'srt-helper:srtChooseDestEditor': () => this.srtChooseDestEditor()
	    }));
  	},

Can anyone help me? What am I doing wrong?


#2

You need to add a comma between the commands:

"submenu": [
        {
          "label": "Srt Helper",
          "submenu": [
            { "label": "...", "command": "..." },
            { "label": "...",	"command": "..."	}
          ]
        }

#3

Hi,

That was the problem! Thanks for the help!