env-editor
Advanced tools
Comparing version 0.5.0 to 1.0.0
304
index.js
@@ -1,145 +0,148 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
import process from 'node:process'; | ||
import path from 'node:path'; | ||
const allEditors = () => [ | ||
{ | ||
id: 'sublime', | ||
name: 'Sublime Text', | ||
binary: 'subl', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', | ||
'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' | ||
], | ||
keywords: [] | ||
}, | ||
{ | ||
id: 'atom', | ||
name: 'Atom', | ||
binary: 'atom', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Atom.app/Contents/Resources/app/atom.sh' | ||
], | ||
keywords: [] | ||
}, | ||
{ | ||
id: 'vscode', | ||
name: 'Visual Studio Code', | ||
binary: 'code', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code' | ||
], | ||
keywords: [ | ||
'vs code' | ||
] | ||
}, | ||
{ | ||
id: 'webstorm', | ||
name: 'WebStorm', | ||
binary: 'webstorm', | ||
isTerminalEditor: false, | ||
paths: [], | ||
keywords: [ | ||
'wstorm' | ||
] | ||
}, | ||
{ | ||
id: 'textmate', | ||
name: 'TextMate', | ||
binary: 'mate', | ||
isTerminalEditor: false, | ||
paths: [], | ||
keywords: [] | ||
}, | ||
{ | ||
id: 'vim', | ||
name: 'Vim', | ||
binary: 'vim', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [] | ||
}, | ||
{ | ||
id: 'neovim', | ||
name: 'NeoVim', | ||
binary: 'nvim', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [ | ||
'vim' | ||
] | ||
}, | ||
{ | ||
id: 'intellij', | ||
name: 'IntelliJ IDEA', | ||
binary: 'idea', | ||
isTerminalEditor: false, | ||
paths: [], | ||
keywords: [ | ||
'idea', | ||
'java', | ||
'jetbrains', | ||
'ide' | ||
] | ||
}, | ||
{ | ||
id: 'nano', | ||
name: 'GNU nano', | ||
binary: 'nano', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [] | ||
}, | ||
{ | ||
id: 'emacs', | ||
name: 'GNU Emacs', | ||
binary: 'emacs', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [] | ||
}, | ||
{ | ||
id: 'emacsforosx', | ||
name: 'GNU Emacs for Mac OS X', | ||
binary: 'Emacs', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Emacs.app/Contents/MacOS/Emacs' | ||
], | ||
keywords: [] | ||
}, | ||
{ | ||
id: 'android-studio', | ||
name: 'Android Studio', | ||
binary: 'studio', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Android Studio.app/Contents/MacOS/studio', | ||
'/usr/local/Android/android-studio/bin/studio.sh', | ||
'C:\\Program Files (x86)\\Android\\android-studio\\bin\\studio.exe', | ||
'C:\\Program Files\\Android\\android-studio\\bin\\studio64.exe' | ||
], | ||
keywords: [ | ||
'studio' | ||
] | ||
}, | ||
{ | ||
id: 'xcode', | ||
name: 'Xcode', | ||
binary: 'xed', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Xcode.app/Contents/MacOS/Xcode', | ||
'/Applications/Xcode-beta.app/Contents/MacOS/Xcode' | ||
], | ||
keywords: [ | ||
'xed' | ||
] | ||
} | ||
]; | ||
export function allEditors() { | ||
return [ | ||
{ | ||
id: 'sublime', | ||
name: 'Sublime Text', | ||
binary: 'subl', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', | ||
'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', | ||
], | ||
keywords: [], | ||
}, | ||
{ | ||
id: 'atom', | ||
name: 'Atom', | ||
binary: 'atom', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Atom.app/Contents/Resources/app/atom.sh', | ||
], | ||
keywords: [], | ||
}, | ||
{ | ||
id: 'vscode', | ||
name: 'Visual Studio Code', | ||
binary: 'code', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code', | ||
], | ||
keywords: [ | ||
'vs code', | ||
], | ||
}, | ||
{ | ||
id: 'webstorm', | ||
name: 'WebStorm', | ||
binary: 'webstorm', | ||
isTerminalEditor: false, | ||
paths: [], | ||
keywords: [ | ||
'wstorm', | ||
], | ||
}, | ||
{ | ||
id: 'textmate', | ||
name: 'TextMate', | ||
binary: 'mate', | ||
isTerminalEditor: false, | ||
paths: [], | ||
keywords: [], | ||
}, | ||
{ | ||
id: 'vim', | ||
name: 'Vim', | ||
binary: 'vim', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [], | ||
}, | ||
{ | ||
id: 'neovim', | ||
name: 'NeoVim', | ||
binary: 'nvim', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [ | ||
'vim', | ||
], | ||
}, | ||
{ | ||
id: 'intellij', | ||
name: 'IntelliJ IDEA', | ||
binary: 'idea', | ||
isTerminalEditor: false, | ||
paths: [], | ||
keywords: [ | ||
'idea', | ||
'java', | ||
'jetbrains', | ||
'ide', | ||
], | ||
}, | ||
{ | ||
id: 'nano', | ||
name: 'GNU nano', | ||
binary: 'nano', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [], | ||
}, | ||
{ | ||
id: 'emacs', | ||
name: 'GNU Emacs', | ||
binary: 'emacs', | ||
isTerminalEditor: true, | ||
paths: [], | ||
keywords: [], | ||
}, | ||
{ | ||
id: 'emacsforosx', | ||
name: 'GNU Emacs for Mac OS X', | ||
binary: 'Emacs', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Emacs.app/Contents/MacOS/Emacs', | ||
], | ||
keywords: [], | ||
}, | ||
{ | ||
id: 'android-studio', | ||
name: 'Android Studio', | ||
binary: 'studio', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Android Studio.app/Contents/MacOS/studio', | ||
'/usr/local/Android/android-studio/bin/studio.sh', | ||
'C:\\Program Files (x86)\\Android\\android-studio\\bin\\studio.exe', | ||
'C:\\Program Files\\Android\\android-studio\\bin\\studio64.exe', | ||
], | ||
keywords: [ | ||
'studio', | ||
], | ||
}, | ||
{ | ||
id: 'xcode', | ||
name: 'Xcode', | ||
binary: 'xed', | ||
isTerminalEditor: false, | ||
paths: [ | ||
'/Applications/Xcode.app/Contents/MacOS/Xcode', | ||
'/Applications/Xcode-beta.app/Contents/MacOS/Xcode', | ||
], | ||
keywords: [ | ||
'xed', | ||
], | ||
}, | ||
]; | ||
} | ||
const getEditor = editor => { | ||
export function getEditor(editor) { | ||
editor = editor.trim(); | ||
const needle = editor.toLowerCase(); | ||
@@ -152,5 +155,5 @@ const id = needle.split(/[/\\]/).pop().replace(/\s/g, '-'); | ||
if ( | ||
needle === editor.id || | ||
needle === editor.name.toLowerCase() || | ||
binary === editor.binary | ||
needle === editor.id | ||
|| needle === editor.name.toLowerCase() | ||
|| binary === editor.binary | ||
) { | ||
@@ -179,7 +182,7 @@ return editor; | ||
paths: [], | ||
keywords: [] | ||
keywords: [], | ||
}; | ||
}; | ||
} | ||
module.exports.defaultEditor = () => { | ||
export function defaultEditor() { | ||
const editor = process.env.EDITOR || process.env.VISUAL; | ||
@@ -195,3 +198,3 @@ | ||
export EDITOR=atom | ||
` | ||
`, | ||
); | ||
@@ -201,5 +204,2 @@ } | ||
return getEditor(editor); | ||
}; | ||
module.exports.getEditor = getEditor; | ||
module.exports.allEditors = allEditors; | ||
} |
{ | ||
"name": "env-editor", | ||
"version": "0.5.0", | ||
"version": "1.0.0", | ||
"description": "Get metadata on the default editor or a specific editor", | ||
"license": "MIT", | ||
"repository": "sindresorhus/env-editor", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -49,6 +52,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^2.4.0", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
@@ -7,3 +7,2 @@ # env-editor | ||
## Supported editors | ||
@@ -30,7 +29,6 @@ | ||
## Usage | ||
```js | ||
const {defaultEditor, getEditor, allEditors} = require('env-editor'); | ||
import {defaultEditor, getEditor, allEditors} from 'env-editor'; | ||
@@ -82,3 +80,2 @@ defaultEditor(); | ||
## API | ||
@@ -85,0 +82,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8972
1
Yes
101