Skip to content

WasabiThumb/winsn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

winsn

Windows Path Short Name (GetShortPathNameW) for NodeJS

Usage

Convert a long path name to short path name:

const shortName = require("winsn");
shortName("C:\\Program Files"); // C:\PROGRA~1

Handle non-Windows OS:

const shortName = require("winsn");
if (shortName.isAvailable()) {
    shortName("C:\\Program Files (x86)"); // C:\PROGRA~2
}

Handle potentially invalid long path name:

const shortName = require("winsn");
const long = "Q:\\nonexistent";
let short;

short = shortName.elseNull(long); // null (all host machines!)
console.log(`${long} -> ${short}`); // Q:\nonexistent -> null

short = shortName.elseLong(long); // Q:\nonexistent
console.log(`${long} -> ${short}`); // Q:\nonexistent -> Q:\nonexistent

Why

  • Flexibility in cross-platform toolkits that assume unix-like paths where no whitespace or quotes are allowed
  • Reduce console clutter
  • 🤷

About

Windows Path Short Name for NodeJS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors