-
fs.realpath('/etc/passwd', function(err, path) { /* "/private/etc/passwd" */
-});
+
-dir = path.join('etc', 'passwd');
-dir = path.resolve('/etc', 'passwd', '..', 'var');
+
-path.dirname('/etc/passwd') //=> "/etc"
-path.basename('/etc/passwd') //=> "passwd"
-path.basename('/etc/rc.d', '.d') //=> "rc"
+
+
+
Quick reference to the Node.js path API.
+
+
+
+
+
+ Functions
+
+const fs = require('fs')
+
+fs.realpath('/etc/passwd', function (err, path) {
+ path // => "/private/etc/passwd"
+})
+
+
+const path = require('path')
+dir = path.join('etc', 'passwd')
+dir = path.resolve('/etc', 'passwd', '..', 'var')
+
+
+path.dirname('/etc/passwd') // => "/etc"
+path.basename('/etc/passwd') // => "passwd"
+path.basename('/etc/rc.d', '.d') // => "rc"
References
- - http://nodejs.org/api/path.html
+ - https://nodejs.org/api/path.html
+
+
+ + 0 Comments + + for this cheatsheet. + Write yours! +
+