当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs.lstat函数代码示例

本文整理汇总了TypeScript中fs.lstat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lstat函数的具体用法?TypeScript lstat怎么用?TypeScript lstat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lstat函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: search

      names.forEach(file => {
        file = path.join(directory, file);
        if (ignore(file)) {
          return;
        }
        activeCalls++;

        fs.lstat(file, (err, stat) => {
          activeCalls--;

          if (!err && stat && !stat.isSymbolicLink()) {
            if (stat.isDirectory()) {
              search(file);
            } else {
              const ext = path.extname(file).substr(1);
              if (extensions.indexOf(ext) !== -1) {
                result.push([file, stat.mtime.getTime(), stat.size]);
              }
            }
          }
          if (activeCalls === 0) {
            callback(result);
          }
        });
      });
开发者ID:Volune,项目名称:jest,代码行数:25,代码来源:node.ts

示例2: link

export function link(sourcePath: string,
                     targetPath: string,
                     ignoreFunction: (file: string) => boolean,
                     callback: (error?: Error) => void) {
  lstat(sourcePath, (error, sourceStats) => {
    if (error) return callback(error);
    if (sourceStats.isDirectory()) {
      // if source is a directory, mkdir a new directory at targetPath and recurse
      mkdir_p(targetPath, error => {
        if (error) return callback(error);
        readdir(sourcePath, (error, files) => {
          if (error) return callback(error);
          const sourcePairs = files.map(file => [file, join(sourcePath, file)]);
          const includedSourcePairs = sourcePairs.filter(([_, source]) => !ignoreFunction(source));
          async.each(includedSourcePairs, ([file, source], callback) => {
            const target = join(targetPath, file);
            link(source, target, ignoreFunction, callback);
          }, callback);
        });
      });
    }
    else if (sourceStats.isSymbolicLink() || sourceStats.isFile()) {
      log(`${sourcePath} <- ${targetPath}`);
      // type declarations are incorrect; symlink should be overloaded with three arguments
      symlink(sourcePath, targetPath, null, callback);
    }
    else {
      callback(new Error(`Cannot link unusual source file: "${sourcePath}"`));
    }
  });
}
开发者ID:chbrown,项目名称:npm-reallink,代码行数:31,代码来源:index.ts

示例3: Promise

  return new Promise((resolve, _) => {
    Fs.lstat(path, (err, stat) => {
      if (err) {
        resolve([])
      } else {
        if (stat.isDirectory()) {
          Fs.readdir(path, (readDirErr, paths) => {
            if (readDirErr) {
              resolve([])
            } else {
              const files = paths.map(p =>
                FsUtil.getStats(Path.join(path, p))
                  .then(s => (s.isFile() ? [Path.basename(p)] : []))
                  .catch(() => []),
              )

              resolve(Promise.all(files).then(ArrayUtil.flatten))
            }
          })
        } else if (stat.isFile()) {
          resolve([Path.basename(path)])
        } else {
          // Something else.
          resolve([])
        }
      }
    })
  })
开发者ID:maximbaz,项目名称:bash-language-server,代码行数:28,代码来源:executables.ts

示例4: function

  var printLink = function(err, res){
    if(err) {
	  console.error(err);
      cb(err);
      return;
    }

    var linkList = [to];
    var lstatCb =  function(file, err, stats){
      if(err){
        console.error("Link target %s not found", file);
        return;
      }
      if(stats.isSymbolicLink()){
        fs.readlink(file, function(err, linkString){
          linkList.push(linkString);
          fs.lstat(linkString, lstatCb.bind(null,linkString));
        });
      } else {
        console.log(linkList.join(" -> "));
        cb(null);
      }
    }
    fs.lstat(to,lstatCb.bind(null,to));

  }
开发者ID:Cellule,项目名称:tsd-link,代码行数:26,代码来源:utils.ts

示例5: handleEvent

  private handleEvent(filepath: string) {
    const relativePath = path.relative(this.root, filepath);
    if (!this.isFileIncluded(relativePath)) {
      return;
    }

    fs.lstat(filepath, (error, stat) => {
      if (error && error.code !== 'ENOENT') {
        this.emit('error', error);
        return;
      }

      if (error) {
        // Ignore files that aren't tracked and don't exist.
        if (!this._tracked.has(filepath)) {
          return;
        }

        this._emit(DELETE_EVENT, relativePath);
        this._tracked.delete(filepath);
        return;
      }

      if (this._tracked.has(filepath)) {
        this._emit(CHANGE_EVENT, relativePath, stat);
      } else {
        this._tracked.add(filepath);
        this._emit(ADD_EVENT, relativePath, stat);
      }
    });
  }
开发者ID:facebook,项目名称:jest,代码行数:31,代码来源:FSEventsWatcher.ts

示例6: reject

 return new Promise<fs.Stats>((resolve, reject) => {
   fs.lstat(path, (err, stats) => {
     if (err) {
       return reject(err);
     }
     resolve(stats);
   });
 });
开发者ID:pilwon,项目名称:node-get-config,代码行数:8,代码来源:fs.ts

示例7: Promise

 return new Promise((resolve, reject) => {
     fs.lstat(path, (err, stats) => {
         if (err) {
             return reject(err)
         }
         resolve(stats.isDirectory())
     })
 })
开发者ID:Gruntfuggly,项目名称:vscode-quick-browser,代码行数:8,代码来源:extension.ts

示例8: Promise

 return new Promise((resolve, reject) => {
   Fs.lstat(path, (err, stat) => {
     if (err) {
       reject(err)
     } else {
       resolve(stat)
     }
   })
 })
开发者ID:maximbaz,项目名称:bash-language-server,代码行数:9,代码来源:fs.ts

示例9: if

	fs.readdir(home, (err, dirs) => {
		if (err) throw err;

		for (const dir of dirs.map(d => path.join(home, d))) {
			fs.lstat(dir, (err, stats) => {
				if(dir.indexOf('.git') > 0) return;

				if (err) throw err;
				if (stats.isDirectory()) {
					checkDir(dir, count + 1);
					fs.readdir(dir, (err, files) => {
						if (err) throw err;
						const target = path.join(dir, 'tsconfig.json');
						fs.exists(target, exists => {
							if (exists) {
								const old = JSON.parse(fs.readFileSync(target, 'utf-8'));

								let entryPoint: string = undefined;
								let definitionFiles = files.filter(f => (f.indexOf('.d.ts') > 0));
								if (definitionFiles.length === 1) {
									entryPoint = definitionFiles[0];
								} else if(fs.existsSync(path.join(dir, 'index.d.ts'))) {
									entryPoint = 'index.d.ts';
								} else {
									entryPoint = path.basename(dir) + '.d.ts';
								}

								if (!fs.existsSync(path.join(dir, entryPoint))) {
									console.log('No file ' + entryPoint + ' exists in ' + dir + ' so deleting it');
									fs.unlink(target);
									return;
								}

								let testFile = path.join(dir, path.basename(dir) + '-tests.ts');
								if (!fs.existsSync(testFile)) {
									let onlyTest = files.filter(f => f.toLowerCase().indexOf('-tests.ts') > 0)[0];
									if (onlyTest) {
										testFile = path.join(dir, onlyTest);
									} else {
										testFile = undefined;
									}
								}
								if (testFile) {
									old['files'] = ['index.d.ts', path.basename(testFile)];
								} else {
									old['files'] = ['index.d.ts'];
								}

								fs.writeFileSync(target, JSON.stringify(old, undefined, 4));
								console.log('Write to ' + target);
							}
						});
					});
				}
			});
		}
	});
开发者ID:rchaser53,项目名称:DefinitelyTyped,代码行数:57,代码来源:rename-entry-points.ts

示例10:

	fs.readdir(home, (err, dirs) => {
		if (err) throw err;
		for (const dir of dirs) {
			const fullPath = path.join(home, dir);
			fs.lstat(fullPath, (err, stats) => {
				if (err) throw err;			
				if (stats.isDirectory()) {
					callback(fullPath, dir);
				}
			});
		}
	});
开发者ID:KostyaTretyak,项目名称:DefinitelyTyped,代码行数:12,代码来源:delete-tscparams.ts


注:本文中的fs.lstat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。