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

windows

v0.1.2

Published

A collection of utilities for Windows for Node.js

Downloads

482

Readme

Node Utilities for Windows

Right now it's just a few wrappers around some builtin console commands but FFI bindings are soon to come.

Command line tools

Some wrappers for the below APIs to be used on the command line.


cwddrive                          alias a random available drive letter to current working directory
cwddrive L                        alias L to CWD if not taken, or toggles it off if it currently is L
cwddrive L C:/some/folder         alias L to C:/some/folder if available

makerunnable f1.js [f2.js] ...    creates a .cmd file in npm.globalBin (is in PATH) that will exec the .js

APIs


driveAlias('x', folder)                  // alias a folder to `X:\`
driveAlias('x')                          // remove aliased `X:\` folderdrive
driveAlias()                             // list all aliased drives


runnable(['myCLI.js',...],function(r){   // for each js file given a %name%.cmd will be
  'NPMGLOBALBIN/myCLI.cmd created'       // create in the npm global bin directory that
    // or                                // will launch the given js file. npm's globalBin
  'Could not find myCLI.js'              // is added to PATH by default on installation
});


associations('.js'. 'jscript')           // add or change extension to type map
associations('.js')                      // retrieve type
associations()                           // list all extension -> types

fileTypes('jscript'. process.execPath)   // add or change program that handles a filetype
                                         // (example sets node as javascript's handler)
fileTypes('jscript')                     // retrieve handler for the type
fileTypes()                              // list all type -> handlers


getFontNames()                           // list all the fonts in the registry by type


findWindowsSDK() //-->                   // simply utility for detecting installed Windows
  { path: winSDKfolder,                  // SDKs (header files). Returns null if not found.
    versions: [8, 9, 10] }


registry(key, options)                   // returns an object containing the keys and values

v = registry('HKLM/Software/Microsoft'   // wrapped in objects allowing further fluent commands
v.someValue.remove()                     // delete value
v.add('newValue', 'myValue')             // add new value
v.add('newKey')                          // a key is like a folder
v.subKey                                 // getter which goes down one level deeper

x = registry('HKCU/Some/Random/Place')
x.add('newName', v.someValue)            // clone a value

z = v.aValue                             // manipulate wrapped values even after deleting them
z.remove()
v.add(z.name, z)  //oops undo

v.remove()                               // delete a key and all its contents recursively
v.remove('name')                         // just delete a child (key or value)


options = { search    : 'query',         // all options are optional
            recursive : false,
            case      : false,
            exact     : false,
            in        : 'keys' || 'values',
            type      : 'REG_SZ'     || 'REG_MULTI_SZ'  || 'REG_DWORD' ||
                        'REG_BINARY' || 'REG_EXPAND_SZ' || 'REG_QWORD' ||
                        'REG_NONE' }


// The raw commands are provided as well but are annoying to use directly

registry.query
registry.add
registry.delete
registry.copy
registry.save
registry.restore
registry.load
registry.unload
registry.compare
registry.export
registry.import
registry.flags


execSync('cmd' ...)                     // executes the command synchronously and returns the result,
                                        // flattening all params down to spaced delineation

Command(command, name, formatter)       // create a wrapped execSync calling function that executes
                                        // the command when called. Name and formatter are optiona,
                                        // with the default formatter splits the result into an array of lines




function parseCSV(str){
  return str.trim().split(/\r?\n/).map(function(str){
    return JSON.parse('['+str+']');
  });
  return str;
}

var nodes = Command('tasklist /fo csv /fi "imagename eq node.exe"', 'nodes', parseCSV);

nodes();

//  [ [ 'Image Name', 'PID', 'Session Name', 'Session#', 'Mem Usage' ],
//    [ 'node.exe', '6524', 'Console', '3', '13,060 K' ] ]