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


TypeScript fs-extra-promise.existsSync函数代码示例

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


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

示例1: Error

    return fs.lstatAsync(filePathOrFolder).then(stats => {
        // If a file path was passed, assume its the launch file.
        if (stats.isFile()) {
            return filePathOrFolder;
        }

        // Otherwise, search the specified folder.
        let candidate: string;
        
        candidate = path.join(filePathOrFolder, runFileName);
        if (fs.existsSync(candidate)) {
            return candidate;
        }
        
        candidate = path.join(filePathOrFolder, omnisharpFileName);
        if (fs.existsSync(candidate)) {
            return candidate;
        }
        
        candidate = path.join(filePathOrFolder, omnisharpExeFileName);
        if (fs.existsSync(candidate)) {
            return candidate;
        }
        
        throw new Error(`Could not fnd launch file in ${filePathOrFolder}. Expected '${runFileName}', '${omnisharpFileName}', or '${omnisharpExeFileName}'.`);
    });
开发者ID:bertlacy,项目名称:omnisharp-vscode,代码行数:26,代码来源:path.ts

示例2: formatByTimestamp

function formatByTimestamp() {

  const FIVE_MINUTES = 1000 * 60 * 5
  const timestampPath = jd('timestamp.txt')
  const now = new Date()

  if (fsep.existsSync(timestampPath)) {

    const oldTimestamp = fsep.readFileSync(timestampPath).toString()
    const oldDate = new Date(oldTimestamp)
    const difference = now.valueOf() - oldDate.valueOf()

    if (difference > FIVE_MINUTES) {
      log('Running 5 minute code format')
      updateTimestamp()
      soFormatDefinitely()
    } else {
      log(ms(FIVE_MINUTES - difference) + ' to next format')
      return
    }

  }

  updateTimestamp()

  function updateTimestamp() {
    fsep.writeFileSync(timestampPath, now.toISOString())
  }

}
开发者ID:Edward-Lombe,项目名称:elm-electron,代码行数:30,代码来源:maybe-format.ts

示例3:

 executableFiles.forEach(element => {
     let executableFile = path.join(filePath, element);
     if (candidate === undefined && fs.existsSync(executableFile)) {
         candidate = executableFile;
         return candidate;
     }
 });
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:7,代码来源:server.ts

示例4: optionallyModifyWebpackConfig

function optionallyModifyWebpackConfig(
  options: WebpackConfig | WebpackConfig[],
  command: Command
) {
  const path = join(process.cwd(), 'ws.config.js');
  const exists = existsSync(path);
  if (exists) {
    const modifyWebpackConfig = __non_webpack_require__(path);
    modifyWebpackConfig(command, options);
  }
}
开发者ID:otbe,项目名称:ws,代码行数:11,代码来源:compiler.ts

示例5: Error

    return fs.lstatAsync(filePath).then(stats => {
        // If a file path was passed, assume its the launch file.
        if (stats.isFile()) {
            return filePath;
        }

        // Otherwise, search the specified folder.
        let candidate: string;
        
        candidate = path.join(filePath, 'OmniSharp.exe');
        if (fs.existsSync(candidate)) {
            return candidate;
        }
        
        candidate = path.join(filePath, 'OmniSharp');
        if (fs.existsSync(candidate)) {
            return candidate;
        }
        
        throw new Error(`Could not find OmniSharp launch file in ${filePath}.`);
    });
开发者ID:Firaenix,项目名称:omnisharp-vscode,代码行数:21,代码来源:omnisharp.ts

示例6: addAssetsIfNecessary

export function addAssetsIfNecessary(server: OmnisharpServer) {
    if (!vscode.workspace.rootPath) {
        return;
    }
    
    // If there is no project.json, we won't bother to prompt the user for tasks.json.		
    const projectJsonPath = path.join(vscode.workspace.rootPath, 'project.json');		
    if (!fs.existsSync(projectJsonPath)) {
        return;
    }

    return serverUtils.requestWorkspaceInformation(server).then(info => {
        // If there are no .NET Core projects, we won't bother offering to add assets.
        if ('DotNet' in info && info.DotNet.Projects.length > 0) {
            return getOperations().then(operations => {
                if (!hasOperations(operations)) {
                    return;
                }
                
                promptToAddAssets().then(addAssets => {
                    if (!addAssets) {
                        return;
                    }
                    
                    const paths = getPaths();
                    
                    return fs.ensureDirAsync(paths.vscodeFolder).then(() => {
                        return Promise.all([
                            addTasksJsonIfNecessary(info.DotNet, paths, operations),
                            addLaunchJsonIfNecessary(info.DotNet, paths, operations)
                        ]);
                    });
                });
            });
        }
    });
}
开发者ID:Jeffiy,项目名称:omnisharp-vscode,代码行数:37,代码来源:assets.ts

示例7: validate

export function validate(pkg: any): PackageConfig {
  if (!pkg.ws) {
    throw `Your ${yellow('package.json')} needs a ${yellow(
      'ws'
    )} config. It could look like this:${sampleConfig}`;
  }

  if (!pkg.ws.type) {
    throw `You need to specify a ${yellow(
      'type'
    )}. This can be any of the following values: ${yellow(TYPES.join(', '))}.`;
  }

  if (!TYPES.some((type) => type === pkg.ws.type)) {
    throw `Your type ${yellow(
      pkg.ws.type
    )} doesn't match any of the valid values: ${yellow(TYPES.join(', '))}.`;
  }

  if (!pkg.name) {
    throw `You need to specify a ${yellow('name')} in your package.json.`;
  }

  if (!pkg.ws.srcDir) {
    pkg.ws.srcDir = 'src';
  }

  if (!pkg.ws.testsDir) {
    pkg.ws.testsDir = 'tests';
  }

  if (!pkg.ws.distDir) {
    pkg.ws.distDir = 'dist';
  }

  if (!pkg.ws.distTestsDir) {
    pkg.ws.distTestsDir = 'dist-tests';
  }

  if (!pkg.ws.distReleaseDir) {
    pkg.ws.distReleaseDir = 'dist-release';
  }

  if (pkg.ws.i18n && !pkg.ws.i18n.dir) {
    pkg.ws.i18n.dir = 'i18n';
  }

  if (pkg.ws.i18n && !pkg.ws.i18n.distDir) {
    pkg.ws.i18n.distDir = 'dist-i18n';
  }

  // check if this project is using typescript (and tsx)
  const tsconfigRoot = join(process.cwd(), 'tsconfig.json');
  const tsconfigSrc = join(process.cwd(), pkg.ws.srcDir, 'tsconfig.json');
  if (existsSync(tsconfigSrc)) {
    pkg.ws.tsconfigPath = tsconfigSrc;
  } else if (existsSync(tsconfigRoot)) {
    pkg.ws.tsconfigPath = tsconfigRoot;
  }
  if (pkg.ws.tsconfigPath) {
    const { config } = readConfigFile(pkg.ws.tsconfigPath, sys.readFile);
    const host = {
      useCaseSensitiveFileNames: false,
      readDirectory: sys.readDirectory,
      fileExists: sys.fileExists,
      readFile: sys.readFile
    };
    const { options } = parseJsonConfigFileContent(
      config,
      host,
      basename(pkg.ws.tsconfigPath)
    );
    if (options) {
      pkg.ws.tsconfig = options;
      if (options.jsx) {
        pkg.ws.entryExtension = 'tsx';
      } else {
        pkg.ws.entryExtension = 'ts';
      }
    }
  } else {
    pkg.ws.entryExtension = 'js';
  }

  // entry files
  pkg.ws.srcEntry = `./${pkg.ws.srcDir}/index.${pkg.ws.entryExtension}`;
  pkg.ws.srcI18nEntry = `./${pkg.ws.srcDir}/index.i18n.${
    pkg.ws.entryExtension
  }`;
  pkg.ws.unitEntry = `./${pkg.ws.testsDir}/unit.${pkg.ws.entryExtension}`;
  pkg.ws.e2eEntry = `./${pkg.ws.testsDir}/e2e.${pkg.ws.entryExtension}`;

  if (!pkg.ws.publicPath) {
    pkg.ws.publicPath = '';
  }

  // defaults for browsers
  if (!pkg.ws.targets) {
    pkg.ws.targets = {};
  }
//.........这里部分代码省略.........
开发者ID:Mercateo,项目名称:ws,代码行数:101,代码来源:project.ts


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