files.forEach(function(file) { // get info from files FS.stat(path.join(__dirname, file)) .then(function(stats) { if (stats.isFile()) { // remove first path var allPaths = file.split(path.sep); var allPath2 = allPaths.splice(1); var destinationPath = path.join(__dirname, 'syntax', allPath2[0], allPath2[1]); // create new "syntax" folder var dirToMake = path.join(__dirname, 'syntax', allPath2[0]); console.log('\n>>---------\n dirToMake:', dirToMake, '\n>>---------\n'); FS.makeTree(dirToMake) .then(function() { // write syntax rewriter.writeSyntax(path.join(__dirname, file), destinationPath) .then(function() { allSyntaxes.push(destinationPath); }); }).catch(function(err) { reject(err); }); } }) .catch(function(err) { reject(err); }); });
function getLogInfo ( pathToLog ) { return QFS.stat(pathToLog) .then(function(stat){ return Q.all([ QFS.open(pathToLog, { falgs : 'r', end : 50 }).then(getReaden), QFS.open(pathToLog, { falgs : 'r', begin : stat.size - 12, // 9 digits left, so 999 999 999 is max number end : stat.size }).then(getReaden) ]).spread(function(begin, end){ var started = begin.replace(/^log\screated\sat\s(\d+)\n[\s\S]+/, '$1'), quantity = end.replace(/[\s\S]*%%(\d+)\n$/, '$1') || 0; return /^\d+$/.test(started) && /^\d+$/.test(quantity) ? Q.resolve({ started : started, quantity : quantity }) : Q.reject('wrong format of the log file') // TODO use log.error }) }) }
function getTree (path, opts) { // get node prop var node= genNode(path, opts); return Q.when(FS.stat(path)) .then(function (stat) { if(stat.isDirectory()){ // dir node.type= 'dir'; return Q.when(FS.list(path)) .then(preprocessList(opts)) .then(function (children) { var dependents= children.map(function (child) { var childPath = path+'/'+child; return getTree(childPath, opts); }) return Q.all(dependents).then(function (nodes) { if(!opts.showEmptyChildren && nodes.length>0) node.children= nodes; return node; }) }) }else{ // file node.type='file'; return node; } }); }
return qio.exists(timestampFilePath).then(function(exists){ if (!exists) { return null; } return qio.stat(timestampFilePath); });
function existsAndNonZero(path) { return qio.stat(path) .then(function(file) { return !(file.size === 0); }, function() { return false; }); }
genFreeStream(){ return qfs.stat(this.data.filename).then((o)=>{ return { type: this.data.type, size: o.size, stream: fs.createReadStream(this.data.filename), }; }) }
.then(function(results){ list = results; var promises = []; for (var key in list){ console.log(list[key]) promises.push(fs.stat(path.join(dirPath,list[key]))) } return q.all(promises); })
.then(function(exists) { return ( exists ? (qfs.stat(filepath) .then(function(stat) { return [exists, stat.isFile()]; })) : [exists]); })
return Tools.series(list, function(file) { return FS.stat(path + "/" + file).then(function(stat) { var a = `<a rel="${Tools.toHtml(dir + file)}">${Tools.toHtml(file)}</a>`; if (stat.isDirectory()) c.reply += `<li class="directory collapsed">${a}</li>`; else if (stat.isFile()) c.reply += `<li class="file ext_${file.split(".").pop() || ""}">${a}</li>`; return Promise.resolve(); }); });
.then(nodePaths => Promise.all(nodePaths.map(nodePath => { return fs.stat(nodePath) .then(stats => { if(!stats.isFile()) { return; } return localizeFile(nodePath); }); })));
return Q.all(files.map(function(path) { return qfs.stat(path) .then(function(stat) { return stat.lastModified().getTime(); }, function(err) { if (err.code === "ENOENT") return null; throw err; }); }));
.then(function () { var reelHtml = URL.resolve(module.location, reelModule[2] + ".html"); return FS.stat(URL.parse(reelHtml).pathname) .then(function (stat) { if (stat.isFile()) { module.extraDependencies = [id + ".html"]; } }, function (error) { // not a problem }); });
PackageCleaner.prototype._statMethod = function(p) { return FSQ.stat(p) .catch(function(e) { // if symlink target not exist, skip this error if (e.code === 'ENOENT') { console.warn('Warning file "%s" not exist', e.path); return { path: '', size: 0 }; } throw new Error(e); }); };
return Q.all(filenames.map(function(name) { var path = Path.join(dirname, name); return qfs.stat(path).then(function(stat) { var promise; if (stat.isFile() && /\.(html|json|js|css|markdown|md)$/.test(name)) { promise = self.processFile(path); } else if (stat.isDirectory()){ promise = self.processDirectory(path); } return promise; }); }));
var findPackage = function (path) { var directory = FS.directory(path); if (directory === path) { throw new Error("Can't find package"); } var packageJson = FS.join(directory, "package.json"); return FS.stat(path) .then(function (stat) { if (stat.isFile()) { return directory; } else { return findPackage(directory); } }); };
children.forEach(function(path) { pending.push(fs.stat(path).then( function(stats) { if (stats.isFile()) { var name = pathUtils.basename(path).split('.')[0]; self.log(Log.DEBUG, 'loading view ' + pathUtils.basename(path)); return fs.read(path).then( function(data) { self.addView(name, new type(data.toString())); } ) } } )); });
exports.expandPath = function expandPath(path) { return fs.stat(path) .then(function(stat) { if (!stat.isDirectory()) { return [path]; } return fs.listTree(path, function(path) { return fs.extension(path) === '.js'; }); }) .fail(function(e) { return []; }) .then(function(paths) { return paths.map(fs.absolute.bind(fs)); }); };
function getMetaDataChunk(filePath) { this.logger.debug("About to parse meta data for the file %s", filePath) return qio.stat(filePath) .then((stats)=>{ if (!stats.size) { this.logger.error("Zero bytes in file %s!", filePath) return Q.reject() } return mp4Utils.extractMetadata(filePath) .then((metaData)=> { metaData.path = filePath metaData.chunkName = path.basename(filePath) this.logger.debug("Extract Metadata for %s: %s", filePath, JSON.stringify(metaData)) return Q.resolve(metaData) }, (err)=> { this.logger.error("Failed to get metadata for file %s: %s", filePath, ErrorUtils.error2string(err)) return Q.reject() }) }) }
let promises = testFiles.map((filePath) => { qfs.stat(filePath).then((stat) => { assert(stat.isFile()); console.log(`ok: ${filePath}`); }, (e) => done(e)); });
.then(function (compiled) { return qfs.stat(path.join(mockConfig.publicDir, "script.js")) .then(function (stat) { assert.isOk(stat.isFile()); }); });
.then(function (compiled) { return qfs.stat(path.join(compiled.posts[0].target, "index.html")) .then(function (stat) { assert.isOk(stat.isFile()); }); });