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


TypeScript fs-extra.exists函数代码示例

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


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

示例1: reject

    return new Promise<Operations>((resolve, reject) => {
        fs.exists(tasksJsonPath, exists => {
            if (exists) {
                fs.readFile(tasksJsonPath, (err, buffer) => {
                    if (err) {
                        return reject(err);
                    }

                    const text = buffer.toString();
                    let tasksConfiguration: tasks.TaskConfiguration;

                    try {
                        tasksConfiguration = tolerantParse(text);
                    }
                    catch (error) {
                        vscode.window.showErrorMessage(`Failed to parse tasks.json file`);
                        return resolve({ updateTasksJson: false });
                    }

                    let buildTasks = getBuildTasks(tasksConfiguration);

                    resolve({ updateTasksJson: buildTasks.length === 0 });
                });
            }
            else {
                resolve({ addTasksJson: true });
            }
        });
    });
开发者ID:eamodio,项目名称:omnisharp-vscode,代码行数:29,代码来源:assets.ts

示例2: validateExistance

/**
 * Validates the existence of the specified file
 *
 * @param {string} projectPath Path to project
 * @param {string} checkPath Absolute path to file to check
 */
async function validateExistance(projectPath: string, checkPath: string) {
  const fileExists = await fs.exists(checkPath);

  if (!fileExists) {
    const friendlyPath = checkPath.replace(projectPath, './');
    throw new Error(`The project doesn't contain a ${friendlyPath}`);
  }
}
开发者ID:ghoullier,项目名称:codesandbox-cli,代码行数:14,代码来源:index.ts

示例3: resolve

 return new Promise<any>(resolve => {
     fs.exists(file, yes => {
         if (yes) {
             return fs.unlink(file, () => resolve());
         }
         resolve();
     });
 });
开发者ID:lzfernandes,项目名称:pythonVSCode,代码行数:8,代码来源:extension.lint.test.ts

示例4: getIndexHTML

/**
 * Return public/index.html contents
 *
 * @param {string} projectPath
 */
async function getIndexHTML(projectPath: string) {
  const indexHTMLPath = path.join(projectPath, 'public', 'index.html');
  const fileExists = await fs.exists(indexHTMLPath);
  if (!fileExists) {
    return '';
  }

  return fs.readFileSync(indexHTMLPath) || '';
}
开发者ID:ghoullier,项目名称:codesandbox-cli,代码行数:14,代码来源:index.ts

示例5: getPackageJSON

/**
 * Return package.json object
 *
 * @param {string} projectPath
 * @returns
 */
async function getPackageJSON(projectPath: string) {
  const packageJSONPath = path.join(projectPath, 'package.json');
  const fileExists = await fs.exists(packageJSONPath);
  if (!fileExists) {
    throw new Error(`The project doesn't have a package.json.`);
  }

  return fs.readJson(packageJSONPath);
}
开发者ID:ghoullier,项目名称:codesandbox-cli,代码行数:15,代码来源:index.ts

示例6: Promise

 return new Promise((resolve, reject) => {
   fs.exists(fileName, (exist) => {
     if (exist) {
       resolve();
     } else {
       reject(new Error(`File ${fileName} was expected to exist but not found...`));
     }
   });
 });
开发者ID:3L4CKD4RK,项目名称:angular-cli,代码行数:9,代码来源:fs.ts

示例7: resolve

 fs.exists(generator.launchJsonPath, exists => {
     if (exists) {
         resolve(true);
     }
     else {
         fs.exists(generator.tasksJsonPath, exists => {
             resolve(exists);
         });
     }
 });
开发者ID:eamodio,项目名称:omnisharp-vscode,代码行数:10,代码来源:assets.ts

示例8: reject

    return new Promise<void>((resolve, reject) => {
        fs.exists(path, exists => {
            if (exists) {
                // TODO: Should we check after unlinking to see if the file still exists?
                fs.unlink(path, err => {
                    if (err) {
                        return reject(err);
                    }

                    resolve();
                });
            }
        });
    });
开发者ID:rlugojr,项目名称:omnisharp-vscode,代码行数:14,代码来源:assets.ts


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