npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vscode-extras

v1.8.1

Published

A collection of utilities for developing vscode extensions.

Downloads

253

Readme

VSCode Extras

A collection of utilities for developing vscode extensions.

Install

npm install --save vscode-extras

Usage

alert

A convenience wrapper around showInformationMessage, showWarningMessage and showErrorMessage.

import {alert} from 'vscode-extras';

alert.error ( 'Some error' );
alert.info ( 'Some information' );
alert.warn ( 'Some warning' );

exec

The re-exported function from nanoexec, for conveniently executing a native binary.

import {exec} from 'vscode-extras';

const {ok, code, stdout, stderr} = await exec ( 'echo', ['example'] );

getActiveFileLanguage

Get the language of the currently active file, if it's a textual one.

import {getActiveFileLanguage} from 'vscode-extras';

const language = getActiveFileLanguage ();

getActiveFilePath

Get the path of the currently active file, which could be either a textual or binary file.

import {getActiveFilePath} from 'vscode-extras';

const filePath = getActiveFilePath ();

getActiveBinaryFilePath

Get the path of the currently active binary file, where binary means the file is not being edited with a textual editor.

import {getActiveBinaryFilePath} from 'vscode-extras';

const filePath = getActiveBinaryFilePath ();

getActiveTextualFilePath

Get the path of the currently active textual file, where textual means the file is being edited with a textual editor.

import {getActiveTextualFilePath} from 'vscode-extras';

const filePath = getActiveTextualFilePath ();

getActiveUntitledFile

Get the current active file, if it's an untitled one.

import {getActiveUntitledFile} from 'vscode-extras';

const file = getActiveUntitledFile ();

file.path; // 'Untitled-1'
file.content; // 'Some content'

getActiveFolderPath

Get the path of the currently active folder, meaning the folder containing the currently active file, or the project root.

import {getActiveFolderPath} from 'vscode-extras';

const folderPath = getActiveFolderPath ();

getConfig

Get the configuration object for a given extension.

import {getConfig} from 'vscode-extras';

const config = getConfig ( 'myExtension' );

getGitRootPath

Infer the path of the nearest git repository, considering the currently open file also.

import {getGitRootPath} from 'vscode-extras';

const rootPath = getGitRootPath ();

getOpenFilesPaths

Get the paths of all the currently open files, across all visible tab groups.

import {getOpenFilesPaths} from 'vscode-extras';

const filesPaths = getOpenFilesPaths ();

getOpenBinaryFilesPaths

Get the paths of all the currently open binary files, across all visible tab groups.

import {getOpenBinaryFilesPaths} from 'vscode-extras';

const filesPaths = getOpenBinaryFilesPaths ();

getOpenTextualFilesPaths

Get the paths of all the currently open textual files, across all visible tab groups.

import {getOpenTextualFilesPaths} from 'vscode-extras';

const filesPaths = getOpenTextualFilesPaths ();

getOpenUntitledFiles

Get the currently open untitled files, across all visible tab groups.

import {getOpenUntitledFiles} from 'vscode-extras';

const files = getOpenUntitledFiles ();

files[0].path; // 'Untitled-1'
files[0].content; // 'Some content'

getPackage

Get the content of the package.json file, as provided by find-up-json, considering the currently open file also.

import {getPackage} from 'vscode-extras';

const pkg = getPackage ();

getPackageRootPath

Infer the path of the nearest folder containing a package.json file, considering the currently open file also.

import {getPackageRootPath} from 'vscode-extras';

const rootPath = getPackageRootPath ();

getProjectRootPath

Infer the root path of the current project, considering the currently open file also.

import {getProjectRootPath} from 'vscode-extras';

const rootPath = getProjectRootPath ();

getProjectRootPaths

Get all the root paths that make up the current workspace.

import {getProjectRootPaths} from 'vscode-extras';

const rootPaths = getProjectRootPaths ();

isInsiders

Check if the current instance of vscode is the insiders one.

import {isInsiders} from 'vscode-extras';

const insiders = isInsiders ();

openInApp

A little wrapper around tiny-browser-open and tiny-open, for opening a file with a custom app.

import {openInApp} from 'vscode-extras';

openInApp ( 'https://example.com', 'firefox' );
openInApp ( '/path/to/project', 'Visual Studio Code' );

openInDiffEditor

A little wrapper around the built-in vscode.diff command.

import {openInDiffEditor} from 'vscode-extras';

const leftFilePath = '/path/to/left/file';
const rightFilePath = '/path/to/right/file';

openInDiffEditor ( leftFilePath, rightFilePath, 'Custom Title' );

openInEditor

A little wrapper around the built-in vscode.open command, with support for TextDocumentShowOptions options.

import vscode from 'vscode';
import {openInEditor} from 'vscode-extras';

openInEditor ( '/path/to/file', {
  preview: false
  viewVolumn: vscode.ViewColumn.Beside
});

openInExternal

A little wrapper around vscode.env.openInExternal, useful for opening a URL in the default browser.

import {openInExternal} from 'vscode-extras';

openInExternal ( 'https://example.com' );

openInWindow

Open a folder in a vscode window, either the current one or a new one.

import {openInWindow} from 'vscode-extras';

openInWindow ( '/path/to/folder' ); // Open in current window
openInWindow ( '/path/to/folder', true ); // Open in new window

prompt

A convenience wrapper around showInformationMessage, showInputBox and showQuickPick.

import {prompt} from 'vscode-extras';

const boolean = await prompt.boolean ( 'Do you want to continue?' );
const string = await prompt.string ( 'Wha is your name?' );
const password = await prompt.password ( 'What is your password?' );
const pick = await prompt.pick ( 'What is your favorite color?', ['red', 'green', 'blue'] );

License

MIT © Fabio Spampinato