Jak sprawdzić rozszerzenie pliku w węźle JS
var path = require('path');
var ext = path.extname('/Users/Refsnes/demo_path.js');
console.log(ext);
Super Starling
var path = require('path');
var ext = path.extname('/Users/Refsnes/demo_path.js');
console.log(ext);
fs.readdir('./', (err, files) => {
files.forEach(file => {
// console.log(file);
// read extension
const extension = file.split(".").pop();
});
})
var path = require('path')
path.extname('index.html')
// returns
'.html'
const path = require('path');
path.extname('index.html');
// Returns: '.html'
path.extname('index.coffee.md');
// Returns: '.md'
path.extname('index.');
// Returns: '.'
path.extname('index');
// Returns: ''
path.extname('.index');
// Returns: ''
path.extname('.index.md');
// Returns: '.md'