{"id":22222037,"url":"https://github.com/fabiospampinato/vscode-extras","last_synced_at":"2025-07-27T16:32:23.276Z","repository":{"id":225895117,"uuid":"767149958","full_name":"fabiospampinato/vscode-extras","owner":"fabiospampinato","description":"A collection of utilities for developing vscode extensions.","archived":false,"fork":false,"pushed_at":"2024-06-17T19:21:40.000Z","size":50,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-06T07:46:39.288Z","etag":null,"topics":["extension","extra","utilities","vscode"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabiospampinato.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fabiospampinato","custom":"https://www.paypal.me/fabiospampinato"}},"created_at":"2024-03-04T19:43:14.000Z","updated_at":"2024-08-24T21:00:43.000Z","dependencies_parsed_at":"2024-06-17T21:28:56.535Z","dependency_job_id":null,"html_url":"https://github.com/fabiospampinato/vscode-extras","commit_stats":null,"previous_names":["fabiospampinato/vscode-extras"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Fvscode-extras","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Fvscode-extras/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Fvscode-extras/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Fvscode-extras/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiospampinato","download_url":"https://codeload.github.com/fabiospampinato/vscode-extras/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227817017,"owners_count":17824200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","extra","utilities","vscode"],"created_at":"2024-12-02T23:16:37.424Z","updated_at":"2024-12-02T23:16:38.087Z","avatar_url":"https://github.com/fabiospampinato.png","language":"TypeScript","funding_links":["https://github.com/sponsors/fabiospampinato","https://www.paypal.me/fabiospampinato"],"categories":[],"sub_categories":[],"readme":"# VSCode Extras\n\nA collection of utilities for developing vscode extensions.\n\n## Install\n\n```sh\nnpm install --save vscode-extras\n```\n\n## Usage\n\n#### `alert`\n\nA convenience wrapper around `showInformationMessage`, `showWarningMessage` and `showErrorMessage`.\n\n```ts\nimport {alert} from 'vscode-extras';\n\nalert.error ( 'Some error' );\nalert.info ( 'Some information' );\nalert.warn ( 'Some warning' );\n```\n\n#### `exec`\n\nThe re-exported function from [`nanoexec`](https://github.com/fabiospampinato/nanoexec), for conveniently executing a native binary.\n\n```ts\nimport {exec} from 'vscode-extras';\n\nconst {ok, code, stdout, stderr} = await exec ( 'echo', ['example'] );\n```\n\n#### `getActiveFileLanguage`\n\nGet the language of the currently active file, if it's a textual one.\n\n```ts\nimport {getActiveFileLanguage} from 'vscode-extras';\n\nconst language = getActiveFileLanguage ();\n```\n\n#### `getActiveFilePath`\n\nGet the path of the currently active file, which could be either a textual or binary file.\n\n```ts\nimport {getActiveFilePath} from 'vscode-extras';\n\nconst filePath = getActiveFilePath ();\n```\n\n#### `getActiveBinaryFilePath`\n\nGet the path of the currently active binary file, where binary means the file is not being edited with a textual editor.\n\n```ts\nimport {getActiveBinaryFilePath} from 'vscode-extras';\n\nconst filePath = getActiveBinaryFilePath ();\n```\n\n#### `getActiveTextualFilePath`\n\nGet the path of the currently active textual file, where textual means the file is being edited with a textual editor.\n\n```ts\nimport {getActiveTextualFilePath} from 'vscode-extras';\n\nconst filePath = getActiveTextualFilePath ();\n```\n\n#### `getActiveUntitledFile`\n\nGet the current active file, if it's an untitled one.\n\n```ts\nimport {getActiveUntitledFile} from 'vscode-extras';\n\nconst file = getActiveUntitledFile ();\n\nfile.path; // 'Untitled-1'\nfile.content; // 'Some content'\n```\n\n#### `getActiveFolderPath`\n\nGet the path of the currently active folder, meaning the folder containing the currently active file, or the project root.\n\n```ts\nimport {getActiveFolderPath} from 'vscode-extras';\n\nconst folderPath = getActiveFolderPath ();\n```\n\n#### `getConfig`\n\nGet the configuration object for a given extension.\n\n```ts\nimport {getConfig} from 'vscode-extras';\n\nconst config = getConfig ( 'myExtension' );\n```\n\n#### `getGitRootPath`\n\nInfer the path of the nearest git repository, considering the currently open file also.\n\n```ts\nimport {getGitRootPath} from 'vscode-extras';\n\nconst rootPath = getGitRootPath ();\n```\n\n#### `getOpenFilesPaths`\n\nGet the paths of all the currently open files, across all visible tab groups.\n\n```ts\nimport {getOpenFilesPaths} from 'vscode-extras';\n\nconst filesPaths = getOpenFilesPaths ();\n```\n\n#### `getOpenBinaryFilesPaths`\n\nGet the paths of all the currently open binary files, across all visible tab groups.\n\n```ts\nimport {getOpenBinaryFilesPaths} from 'vscode-extras';\n\nconst filesPaths = getOpenBinaryFilesPaths ();\n```\n\n#### `getOpenTextualFilesPaths`\n\nGet the paths of all the currently open textual files, across all visible tab groups.\n\n```ts\nimport {getOpenTextualFilesPaths} from 'vscode-extras';\n\nconst filesPaths = getOpenTextualFilesPaths ();\n```\n\n#### `getOpenUntitledFiles`\n\nGet the currently open untitled files, across all visible tab groups.\n\n```ts\nimport {getOpenUntitledFiles} from 'vscode-extras';\n\nconst files = getOpenUntitledFiles ();\n\nfiles[0].path; // 'Untitled-1'\nfiles[0].content; // 'Some content'\n```\n\n#### `getPackage`\n\nGet the content of the `package.json` file, as provided by [`find-up-json`](https://github.com/fabiospampinato/find-up-json), considering the currently open file also.\n\n```ts\nimport {getPackage} from 'vscode-extras';\n\nconst pkg = getPackage ();\n```\n\n#### `getPackageRootPath`\n\nInfer the path of the nearest folder containing a `package.json` file, considering the currently open file also.\n\n```ts\nimport {getPackageRootPath} from 'vscode-extras';\n\nconst rootPath = getPackageRootPath ();\n```\n\n#### `getProjectRootPath`\n\nInfer the root path of the current project, considering the currently open file also.\n\n```ts\nimport {getProjectRootPath} from 'vscode-extras';\n\nconst rootPath = getProjectRootPath ();\n```\n\n#### `getProjectRootPaths`\n\nGet all the root paths that make up the current workspace.\n\n```ts\nimport {getProjectRootPaths} from 'vscode-extras';\n\nconst rootPaths = getProjectRootPaths ();\n```\n\n#### `isInsiders`\n\nCheck if the current instance of vscode is the insiders one.\n\n```ts\nimport {isInsiders} from 'vscode-extras';\n\nconst insiders = isInsiders ();\n```\n\n#### `openInApp`\n\nA little wrapper around [`tiny-browser-open`](https://github.com/fabiospampinato/tiny-browser-open) and [`tiny-open`](https://github.com/fabiospampinato/tiny-open), for opening a file with a custom app.\n\n```ts\nimport {openInApp} from 'vscode-extras';\n\nopenInApp ( 'https://example.com', 'firefox' );\nopenInApp ( '/path/to/project', 'Visual Studio Code' );\n```\n\n#### `openInDiffEditor`\n\nA little wrapper around the built-in `vscode.diff` command.\n\n```ts\nimport {openInDiffEditor} from 'vscode-extras';\n\nconst leftFilePath = '/path/to/left/file';\nconst rightFilePath = '/path/to/right/file';\n\nopenInDiffEditor ( leftFilePath, rightFilePath, 'Custom Title' );\n```\n\n#### `openInEditor`\n\nA little wrapper around the built-in `vscode.open` command, with support for [`TextDocumentShowOptions`](https://code.visualstudio.com/api/references/vscode-api#TextDocumentShowOptions) options.\n\n```ts\nimport vscode from 'vscode';\nimport {openInEditor} from 'vscode-extras';\n\nopenInEditor ( '/path/to/file', {\n  preview: false\n  viewVolumn: vscode.ViewColumn.Beside\n});\n```\n\n#### `openInExternal`\n\nA little wrapper around `vscode.env.openInExternal`, useful for opening a URL in the default browser.\n\n```ts\nimport {openInExternal} from 'vscode-extras';\n\nopenInExternal ( 'https://example.com' );\n```\n\n#### `openInWindow`\n\nOpen a folder in a vscode window, either the current one or a new one.\n\n```ts\nimport {openInWindow} from 'vscode-extras';\n\nopenInWindow ( '/path/to/folder' ); // Open in current window\nopenInWindow ( '/path/to/folder', true ); // Open in new window\n```\n\n#### `prompt`\n\nA convenience wrapper around `showInformationMessage`, `showInputBox` and `showQuickPick`.\n\n```ts\nimport {prompt} from 'vscode-extras';\n\nconst boolean = await prompt.boolean ( 'Do you want to continue?' );\nconst string = await prompt.string ( 'Wha is your name?' );\nconst password = await prompt.password ( 'What is your password?' );\nconst pick = await prompt.pick ( 'What is your favorite color?', ['red', 'green', 'blue'] );\n```\n\n## License\n\nMIT © Fabio Spampinato\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiospampinato%2Fvscode-extras","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiospampinato%2Fvscode-extras","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiospampinato%2Fvscode-extras/lists"}