Activation Commands and Activate package on startup

Hi everyone,

I’m developing a package that requires activation commands as well as package activation on atom startup or on text editor save at the same time, is that feasible?

Thank you,

I read that as an automation script built as a package.

With no activationCommands defined, the package will always activate (maybe you want that). The only other means to restrict activation is to use activationHooks. For example, you can restrict activation to a specific grammar:

// package.json

"activationHooks": [
    "language-html:grammar-used"
  ]

See the Flight Manual for details on available hooks.

Thank you for your answer,

for my case the package has to do many different things among which, actions that require the package to be active for a specific grammar using activation hooks as you pointed out, and actions that should be triggered by the user from the package menu to execute a given process

is it possible to mix the use of both: activation commands and hooks?

Yes, it’s possible

Thanks you Idleberg,
using activation hooks, atom does activate the package but it does not execute this part of the code
lint: function(registerIndie) {
…,
atom.workspace.observeTextEditors((editor) => {
this.subscriptions.add(editor.onDidSave(lintOnSave))
});},
is there something else I should do

trying the code without activation hooks or activation commands the lint function gets executed and gives an output on file save, however I do also need to execute other user commands using activation commands. how to get both working in the same package?

I really appreciate the help

Can you please share the relevant part of your package.json?

“engines”: {
“atom”: “>=1.0.0 <2.0.0”
},
“private”: true,
“activationHooks”: “core:loaded-shell-environment”,
“activationCommands”: {
“atom-workspace”: [
“test:toggle”,
“test:help”
]
},
“providedServices”: {
“linter”: {
“versions”: {
“1.0.0”: “provideLinter”
}
}
},
“consumedServices”: {
“linter-indie”: {
“versions”: {
“1.0.0”: “consumeLinter”
}
}
},
“dependencies”: {
“dotenv”: “^8.1.0”,
“atom-linter”: “^4.3.3”,
“sb-exec”: “^1.0.4”,
“shelljs”: “^0.5.0”,
“fs-extra”: “^0.26.1”,
“tempfile”: “^1.1.0”,
“split-string”: “^0.1.0”,
“named-js-regexp”: “^1.3.1”
},
“devDependencies”: {
“eslint”: “latest”
},
“eslintConfig”: {
“env”: {
“es6”: true,
“browser”: true,
“node”: true
},
“globals”: {
“atom”: true
}
},