Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@
"pinDigests": true
}
],
"ignoreDeps": [
"node"
]
"ignoreDeps": ["node"]
}
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
push:
branches:
- main
pull_request:

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
lint:
timeout-minutes: 10
runs-on: ubuntu-latest
name: 'Lint: node-24, ubuntu-latest'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false

- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8

- name: Set node version to 24
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24
cache: 'pnpm'

- name: Install deps
run: pnpm install

- name: Check formatting
run: pnpm format --check
6 changes: 6 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"singleQuote": true,
"semi": false,
"ignorePatterns": []
}
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ launch(
// callback if failed to launch (optional)
(fileName, errorMsg) => {
// log error if any
}
},
)
```

### Middleware

An express/connect/webpack-dev-server compatible middleware is also available:

``` js
```js
const launchMiddleware = require('launch-editor-middleware')

app.use('/__open-in-editor', launchMiddleware())
Expand All @@ -61,28 +61,28 @@ To launch files, send requests to the server like the following:
### Supported editors

| Value | Editor | Linux | Windows | macOS |
| --------------- | ---------------------------------------------------------------------- | :---: | :-----: | :-: |
| --------------- | ---------------------------------------------------------------------- | :---: | :-----: | :---: |
| `appcode` | [AppCode](https://www.jetbrains.com/objc/) | | | ✓ |
| `atom` | [Atom](https://atom.io/) | ✓ | ✓ | ✓ |
| `atom` | [Atom](https://atom.io/) | ✓ | ✓ | ✓ |
| `atom-beta` | [Atom Beta](https://atom.io/beta) | | | ✓ |
| `brackets` | [Brackets](http://brackets.io/) | ✓ | ✓ | ✓ |
| `clion` | [Clion](https://www.jetbrains.com/clion/) | | ✓ | ✓ |
| `code` | [Visual Studio Code](https://code.visualstudio.com/) | ✓ | ✓ | ✓ |
| `code-insiders` | [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/) | ✓ | ✓ | ✓ |
| `codium` | [VSCodium](https://github.com/VSCodium/vscodium) | ✓ | ✓ | ✓ |
| `cursor` | [Cursor](https://www.cursor.com/) | ✓ | ✓ | ✓ |
| `emacs` | [Emacs](https://www.gnu.org/software/emacs/) | ✓ | | |
| `idea` | [IDEA](https://www.jetbrains.com/idea/) | ✓ | ✓ | ✓ |
| `notepad++` | [Notepad++](https://notepad-plus-plus.org/download/v7.5.4.html) | | ✓ | |
| `pycharm` | [PyCharm](https://www.jetbrains.com/pycharm/) | ✓ | ✓ | ✓ |
| `phpstorm` | [PhpStorm](https://www.jetbrains.com/phpstorm/) | ✓ | ✓ | ✓ |
| `rider` | [Rider](https://www.jetbrains.com/rider/) | ✓ | ✓ | ✓ |
| `rubymine` | [RubyMine](https://www.jetbrains.com/ruby/) | ✓ | ✓ | ✓ |
| `sublime` | [Sublime Text](https://www.sublimetext.com/) | ✓ | ✓ | ✓ |
| `vim` | [Vim](http://www.vim.org/) | ✓ | | |
| `brackets` | [Brackets](http://brackets.io/) | ✓ | ✓ | ✓ |
| `clion` | [Clion](https://www.jetbrains.com/clion/) | | ✓ | ✓ |
| `code` | [Visual Studio Code](https://code.visualstudio.com/) | ✓ | ✓ | ✓ |
| `code-insiders` | [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/) | ✓ | ✓ | ✓ |
| `codium` | [VSCodium](https://github.com/VSCodium/vscodium) | ✓ | ✓ | ✓ |
| `cursor` | [Cursor](https://www.cursor.com/) | ✓ | ✓ | ✓ |
| `emacs` | [Emacs](https://www.gnu.org/software/emacs/) | ✓ | | |
| `idea` | [IDEA](https://www.jetbrains.com/idea/) | ✓ | ✓ | ✓ |
| `notepad++` | [Notepad++](https://notepad-plus-plus.org/download/v7.5.4.html) | | ✓ | |
| `pycharm` | [PyCharm](https://www.jetbrains.com/pycharm/) | ✓ | ✓ | ✓ |
| `phpstorm` | [PhpStorm](https://www.jetbrains.com/phpstorm/) | ✓ | ✓ | ✓ |
| `rider` | [Rider](https://www.jetbrains.com/rider/) | ✓ | ✓ | ✓ |
| `rubymine` | [RubyMine](https://www.jetbrains.com/ruby/) | ✓ | ✓ | ✓ |
| `sublime` | [Sublime Text](https://www.sublimetext.com/) | ✓ | ✓ | ✓ |
| `vim` | [Vim](http://www.vim.org/) | ✓ | | |
| `visualstudio` | [Visual Studio](https://www.visualstudio.com/vs/) | | | ✓ |
| `webstorm` | [WebStorm](https://www.jetbrains.com/webstorm/) | ✓ | ✓ | ✓ |
| `zed` | [Zed](https://zed.dev/) | ✓ | ✓ | ✓ |
| `webstorm` | [WebStorm](https://www.jetbrains.com/webstorm/) | ✓ | ✓ | ✓ |
| `zed` | [Zed](https://zed.dev/) | ✓ | ✓ | ✓ |

### Custom editor support

Expand Down
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import js from "@eslint/js"
import js from '@eslint/js'
import globals from 'globals'

export default [
js.configs.recommended,
{
files: ['packages/**/*.js'],
languageOptions: {
ecmaVersion: 2018, // Node.js 10
ecmaVersion: 2018, // Node.js 10
sourceType: 'commonjs',
globals: globals.node,
},
Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
{
"packageManager": "pnpm@10.4.1",
"private": true,
"scripts": {
"test": "pnpm -r test",
"release": "bumpp",
"lint": "eslint packages --fix"
"lint": "eslint packages --fix",
"format": "oxfmt"
},
"devDependencies": {
"@eslint/js": "^9.32.0",
"bumpp": "^11.0.1",
"eslint": "^9.32.0",
"globals": "^16.3.0",
"lint-staged": "^6.1.1",
"oxfmt": "^0.52.0",
"yorkie": "^1.0.3"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*": [
"oxfmt --no-error-on-unmatched-pattern"
],
"*.js": [
"eslint --fix",
"git add"
]
},
"packageManager": "pnpm@10.4.1",
"gitHooks": {
"pre-commit": "lint-staged"
}
}
4 changes: 1 addition & 3 deletions packages/launch-editor-middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ module.exports = (specifiedEditor, srcRoot, onErrorCallback) => {
const file = url.searchParams.get('file')
if (!file) {
res.statusCode = 500
res.end(
`launch-editor-middleware: required query param "file" is missing.`
)
res.end(`launch-editor-middleware: required query param "file" is missing.`)
} else {
const resolved = file.startsWith('file://') ? file : path.resolve(srcRoot, file)
launch(resolved, specifiedEditor, onErrorCallback)
Expand Down
10 changes: 2 additions & 8 deletions packages/launch-editor-middleware/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ describe('launchEditorMiddleware', () => {
middleware(req, res)

assert.equal(res.statusCode, 500)
assert.equal(
res.body,
'launch-editor-middleware: required query param "file" is missing.'
)
assert.equal(res.body, 'launch-editor-middleware: required query param "file" is missing.')
})

test('launches editor with specified file', async () => {
Expand All @@ -64,10 +61,7 @@ describe('launchEditorMiddleware', () => {
middleware(req, res)

assert.equal(res.statusCode, 500)
assert.equal(
res.body,
'launch-editor-middleware: required query param "file" is missing.'
)
assert.equal(res.body, 'launch-editor-middleware: required query param "file" is missing.')
})

test('returns 500 on invalid URL', async () => {
Expand Down
28 changes: 14 additions & 14 deletions packages/launch-editor-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
"name": "launch-editor-middleware",
"version": "2.13.2",
"description": "express middleware for launching editor",
"main": "index.js",
"files": [
"index.js"
"keywords": [
"editor",
"express",
"middleware"
],
"scripts": {
"test": "node --test --experimental-test-module-mocks"
"homepage": "https://github.com/yyx990803/launch-editor#readme",
"bugs": {
"url": "https://github.com/yyx990803/launch-editor/issues"
},
"license": "MIT",
"author": "Evan You",
"repository": {
"type": "git",
"url": "git+https://github.com/yyx990803/launch-editor.git"
},
"keywords": [
"express",
"middleware",
"editor"
"files": [
"index.js"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "https://github.com/yyx990803/launch-editor/issues"
"main": "index.js",
"scripts": {
"test": "node --test --experimental-test-module-mocks"
},
"homepage": "https://github.com/yyx990803/launch-editor#readme",
"dependencies": {
"launch-editor": "workspace:^"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/launch-editor/editor-info/linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ module.exports = {
'goland.sh': 'goland',
rider: 'rider',
'rider.sh': 'rider',
zed: 'zed'
zed: 'zed',
}
14 changes: 5 additions & 9 deletions packages/launch-editor/editor-info/macos.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ module.exports = {
'/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl',
'/Applications/Visual Studio Code.app/Contents/MacOS/Code': 'code',
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code',
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Code - Insiders':
'code-insiders',
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron':
'code-insiders',
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Code - Insiders': 'code-insiders',
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron': 'code-insiders',
'/Applications/VSCodium.app/Contents/MacOS/Electron': 'codium',
'/Applications/Cursor.app/Contents/MacOS/Cursor': 'cursor',
'/Applications/Trae.app/Contents/MacOS/Electron': 'trae',
'/Applications/Antigravity.app/Contents/MacOS/Electron': 'antigravity',
'/Applications/AppCode.app/Contents/MacOS/appcode':
'/Applications/AppCode.app/Contents/MacOS/appcode',
'/Applications/CLion.app/Contents/MacOS/clion':
'/Applications/CLion.app/Contents/MacOS/clion',
'/Applications/CLion.app/Contents/MacOS/clion': '/Applications/CLion.app/Contents/MacOS/clion',
'/Applications/IntelliJ IDEA.app/Contents/MacOS/idea':
'/Applications/IntelliJ IDEA.app/Contents/MacOS/idea',
'/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea':
Expand All @@ -44,7 +41,6 @@ module.exports = {
'/Applications/MacVim.app/Contents/MacOS/MacVim': 'mvim',
'/Applications/GoLand.app/Contents/MacOS/goland':
'/Applications/GoLand.app/Contents/MacOS/goland',
'/Applications/Rider.app/Contents/MacOS/rider':
'/Applications/Rider.app/Contents/MacOS/rider',
'/Applications/Zed.app/Contents/MacOS/zed': 'zed'
'/Applications/Rider.app/Contents/MacOS/rider': '/Applications/Rider.app/Contents/MacOS/rider',
'/Applications/Zed.app/Contents/MacOS/zed': 'zed',
}
2 changes: 1 addition & 1 deletion packages/launch-editor/editor-info/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ module.exports = [
'rider64.exe',
'Trae.exe',
'zed.exe',
'Antigravity.exe'
'Antigravity.exe',
]
7 changes: 1 addition & 6 deletions packages/launch-editor/get-args.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
const path = require('path')

// normalize file/line numbers into command line args for specific editors
module.exports = function getArgumentsForPosition (
editor,
fileName,
lineNumber,
columnNumber = 1
) {
module.exports = function getArgumentsForPosition(editor, fileName, lineNumber, columnNumber = 1) {
const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, '')
switch (editorBasename) {
case 'atom':
Expand Down
14 changes: 8 additions & 6 deletions packages/launch-editor/guess.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const COMMON_EDITORS_MACOS = require('./editor-info/macos')
const COMMON_EDITORS_LINUX = require('./editor-info/linux')
const COMMON_EDITORS_WIN = require('./editor-info/windows')

module.exports = function guessEditor (specifiedEditor) {
module.exports = function guessEditor(specifiedEditor) {
if (specifiedEditor) {
return shellQuote.parse(specifiedEditor)
}
Expand All @@ -29,7 +29,7 @@ module.exports = function guessEditor (specifiedEditor) {
if (process.platform === 'darwin') {
const output = childProcess
.execSync('ps x -o comm=', {
stdio: ['pipe', 'pipe', 'ignore']
stdio: ['pipe', 'pipe', 'ignore'],
})
.toString()
const processNames = Object.keys(COMMON_EDITORS_MACOS)
Expand All @@ -49,7 +49,9 @@ module.exports = function guessEditor (specifiedEditor) {
}
// Use a partial match to find the running process path. If one is found, use the
// existing path since it can be running from anywhere.
const runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications))
const runningProcess = processList.find((procName) =>
procName.endsWith(processNameWithoutApplications),
)
if (runningProcess !== undefined) {
return [runningProcess]
}
Expand All @@ -63,8 +65,8 @@ module.exports = function guessEditor (specifiedEditor) {
'Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }' +
'"',
{
stdio: ['pipe', 'pipe', 'ignore']
}
stdio: ['pipe', 'pipe', 'ignore'],
},
)
.toString()
const runningProcesses = output.split('\r\n')
Expand All @@ -82,7 +84,7 @@ module.exports = function guessEditor (specifiedEditor) {
// -o comm Need only names column
const output = childProcess
.execSync('ps x --no-heading -o comm --sort=comm', {
stdio: ['pipe', 'pipe', 'ignore']
stdio: ['pipe', 'pipe', 'ignore'],
})
.toString()
const processNames = Object.keys(COMMON_EDITORS_LINUX)
Expand Down
6 changes: 3 additions & 3 deletions packages/launch-editor/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
declare function launchEditor(
file: string,
specifiedEditor?: string | ((fileName: string, errorMessage: string | null) => void),
onErrorCallback?: (fileName: string, errorMessage: string | null) => void
): void;
onErrorCallback?: (fileName: string, errorMessage: string | null) => void,
): void

export = launchEditor;
export = launchEditor
Loading