Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nicolaspadari/macbar

Put your npm scripts in the Macbook touchbar
https://github.com/nicolaspadari/macbar

macbook touchbar vscode-extension

Last synced: about 2 months ago
JSON representation

Put your npm scripts in the Macbook touchbar

Awesome Lists containing this project

README

        

MacBar




Put your npm scripts in the Macbook touchbar

## About

VSCode has support for the Macbook touchbar, but doens't actually do anything useful with it.


With this extension, it will add available scripts from the `package.json` to it when you open a projects that has a package file.


The only catch is that commands have to be predefined in the manifest of the extension, so it cannot be as dynamic as I wish. The solution is list a possible set of scripts and if your package has them, conditionally show the button that runs the script.


Package manager in commands (`nr`) is handled by [@antfu/ni](https://github.com/antfu/ni)

## Build your own:

Clone to local:
```sh
$ npx degit NicolaSpadari/macbar my-macbar
```

Install dependencies:
```sh
$ pnpm install
```

Edit the list of scripts:
```json
// package.json

// ...
"contributes": {
"commands": [
{
"command": "macbar.lint",
"title": "Lint",
"shortTitle": "nr lint"
},
{
"command": "macbar.dev",
"title": "Dev",
"shortTitle": "nr dev"
},
// ...
],
"menus": {
"touchBar": [
{
"command": "macbar.lint",
"group": "scripts",
"when": "macbar.lintExists"
},
{
"command": "macbar.dev",
"group": "scripts",
"when": "macbar.devExists"
},
// ...
]
}
},
// ...
```

Notes:
- `shortTitle` here is used as a field for the command itself
- `macbar.` **must** match the script name (eg: "dev")

Build the extension:
```sh
$ pnpm run generate
```

Install the generated `.vsix` file that will appear in the root of your project