1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| const path = require('path');
console.log('path.sep:', path.sep); console.log('path.delimiter:', path.delimiter); console.log('=====================================================================================') console.log('path.dirname(__filename):', path.dirname(__filename)); console.log('path.extname(__filename):', path.extname(__filename)); console.log('path.basename(__filename):', path.basename(__filename)); console.log('path.basename(__filename):', path.basename(__filename, path.extname(__filename))); console.log('=====================================================================================') console.log('path.parse(__filename)', path.parse(__filename)); console.log('=====================================================================================') console.log(`path.format({ dir: '/Users/devsawd/hello-world', name: 'index', ext: '.js', }));:`, path.format({ dir: '/Users/devsawd/hello-world', name: 'index', ext: '.js', })); console.log('=====================================================================================') console.log('path.normalize('/Users/devsawd/hello-world/index.js'):', path.normalize('/Users/devsawd/hello-world/index.js')); console.log('=====================================================================================') console.log('path.isAbsolute('/users'):', path.isAbsolute('/users')); console.log('path.isAbsolute('./home'):', path.isAbsolute('./home')); console.log('=====================================================================================') console.log(`path.relative('/Users/devsawd/hello-world/index.js', '/Users'));: `, path.relative('/Users/devsawd/hello-world/index.js', '/Users')); console.log('__dirname:', __dirname); console.log('path.join(__dirname, '..', '/Users', '.', 'devsawd'):', path.join(__dirname, '..', '/Users', '.', 'devsawd')); console.log('path.resolve(__dirname, '..', '/Users', '.', 'devsawd'):', path.resolve(__dirname, '..', '/Users', '.', 'devsawd'));
|