Skip to content
Convert Unix style permissions to strings like ls (0755 => 'rwxr-xr-x')
JavaScript Makefile
Failed to load latest commit information.
examples updating style for examples Dec 8, 2012
tests remove unused file, cleanup tests Mar 28, 2015
.gitignore Initial Commit Sep 14, 2012
Makefile
README.md overhaul Aug 17, 2014
package.json overhaul Aug 17, 2014
perms.js overhaul Aug 17, 2014
perms.min.js overhaul Aug 17, 2014

README.md

perms

Convert Unix style permissions to strings like ls (0755 => 'rwxr-xr-x')

Usage

Node.js

var Perms = require('perms');

Web

<script src="perms.min.js"></script>

Examples

Convert a mode to a human-readable string like ls(1) generates

var p = Perms.toString(0755);
console.log(p);

yields

rwxr-xr-x

Also handles special permissions

var p = Perms.toString(6660);
console.log(p);

yields

rwSrwS---

Go backwards as well!

var mode = Perms.toMode('rwxr-xr-t');
console.log(mode);

yields

1755

NOTE: This module makes it super tempting to parse ls(1)... don't do that!

http://mywiki.wooledge.org/ParsingLs

Functions

toMode(s)

Given a string, return the mode suitable for passing to fs.chmod

toString(s)

Given a mode (as an int), return a string suitable for printing to a user

Installation

npm install perms

Tests

npm test

License

MIT License

Something went wrong with that request. Please try again.