How to use the fs.readdir function in fs

To help you get started, we’ve selected a few fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github benwiley4000 / win95-media-player / encodeIcons.js View on Github external
/* eslint-disable no-console */

const base64Img = require('base64-img');
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');

const iconsSrcDir = path.join(__dirname, 'src', 'icons');
const iconsLibDir = path.join(__dirname, 'lib', 'icons');

mkdirp.sync(iconsLibDir);

fs.readdir(path.join(__dirname, 'src', 'icons'), (err, files) => {
  if (err) {
    console.error(err);
    process.exit(1);
  }
  for (const file of files) {
    base64Img.base64(path.join(iconsSrcDir, file), (err, data) => {
      if (err) {
        console.error(err);
        process.exit(1);
      }
      fs.writeFile(
        path.join(iconsLibDir, file + '.js'),
        `module.exports='${data}'`,
        err => {
          if (err) {
            console.error(err);
github billyhoomm / x-blog / utils / cdn_sync.js View on Github external
return new Promise((res, rej) => {
        fs.readdir(path, function(err, files){
            //err错误 , files 文件名列表包含文件夹与文件
            if(err){
                console.log('error:\n' + err);
                rej(-1)
                return;
            }
    
            files.forEach(function(file){
    
                fs.stat(path + '/' + file, function(err, stat){
                    if(err){console.log(err); return;}
                    if(stat.isDirectory()){			
                        // 如果是文件夹遍历
                        explorer(path + '/' + file);
                    }else{
                        // 读出所有的文件
github oaeproject / Hilary / node_modules / oae-preview-processor / lib / processors / file / pdf.js View on Github external
exec(cmd, { timeout: _pdf2htmlEXTimeout }, (err, stdout, stderr) => {
    if (err) {
      log().error({ err, cmd, stdout, stderr }, 'Could not convert page to html');
      return callback({ code: 500, msg: 'Could not convert page to html' });
    }

    // Converting was succesful, get a list of files we generated
    fs.readdir(pagesDir, (err, files) => {
      if (err) {
        log().error(
          { err, contentId: ctx.contentId },
          'Could not read the %s directory to list the files',
          pagesDir
        );
        return callback({ code: 500, msg: 'Could not read the directory' });
      }

      // Only return the page HTML files, ie: page.i.html
      const htmlFiles = _.filter(files, file => {
        return file.split('.')[0] === 'page' && file.split('.').pop() === 'html';
      });

      // Add each HTML to the list of previews that should be stored.
      _.each(htmlFiles, htmlFile => {
github nexus-js / ui / servers / node / node_modules / jsdox / jsdox.js View on Github external
fs.stat(filename, function (err, s) {
      if (!err && s.isDirectory()) {
        fs.readdir(filename, function(err, files) {
          if (err) {
            console.error('Error generating docs for files', filename, err);
            return cb(err);
          }
          files.forEach(function(file) {
            if (file.match(/\.js$/)) {
              oneFile(filename, file, cb), touched++;
            }
          });
          if(!touched) {
            cb();
          }
        });
      } else {
        cb();
      }
github cjdelisle / PacketCrypt / js / PayMaker.js View on Github external
nThen((w) => {
        Fs.readdir(ctx.workdir, w((err, ret) => {
            if (err) { throw err; }
            files = ret.filter((f) => /^paylog_[0-9]+_[a-f0-9]+.bin$/.test(f));
        }));
    }).nThen((w) => {
        if (!files.length) { return; }
github Autodesk-Forge / forge.commandline-nodejs / api / utils.js View on Github external
return (new Promise((fulfill, reject) => {
			fs.readdir(pathname, (err, files) => {
				if (err)
					reject(err);
				else
					fulfill(files);
			});
		}));
	}
github Lucifier129 / Lucifier129.github.io / lab / tree.js View on Github external
return new Promise(function(resolve, reject) {
        fs.readdir(path, function(err, files) {
            err ? reject(err) : resolve(files)
        })
    })
}
github louis-tru / ngui / node_modules / ngui-utils / fs.js View on Github external
function readdir(err) {
		if (err) 
			return cb(err);
		fs.readdir(path, function (err, ls) {
			if (err) 
				return cb (err);
			list = ls;
			shift();
		});
	}

fs

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

70 / 100
Full package analysis