• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript node-file-exists.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: readFile

export default function readFile(dir: string, file: string): Object|boolean {
  const pathToFile = join(dir, file);
  if (!fileExists(pathToFile)) { return false; }
  try {
    return JSON.parse(readFileSync(pathToFile, 'utf8'));
  } catch (e) {
    return null;
  }
}
开发者ID:coderoad,项目名称:builder-coderoad,代码行数:9,代码来源:readFile.ts


示例2: commandLine

export default function commandLine(root: string,
  commands?: string): Promise<string> {

  // use root path for mac/linux (usr/local/bin, usr/bin), or windows (root)
  if (process.platform === 'darwin' && process.resourcesPath) {
    const localPath = '/usr/local/bin/' + root;
    const globalPath = '/usr/bin/' + root;
    if (fileExists(localPath)) {
      root = localPath;
    } else if (fileExists(globalPath)) {
      root = globalPath;
    } else {
      throw root + ' not found.';
    }
  }

  const run = exec(`${root}${commands ? ' ' + commands : ''}`);

  return new Promise((resolve, reject) => {
    run.stdout.on('data', data => resolve(data));
    run.stderr.on('data', data => reject(data));
  });
}
开发者ID:ShMcK,项目名称:atom-plugin-command-line,代码行数:23,代码来源:index.ts


示例3: configRunner

export default function configRunner(name: string, runner: string, dir: string): () => any {
  // test runner dir
  let flatDep = join(
    dir, 'node_modules', runner, 'package.json'
  );
  let treeDep = join(
    dir, 'node_modules', name, 'node_modules', runner, 'package.json'
  );

  let runnerMain;
  let runnerRoot;
  if (fileExists(flatDep)) {
    runnerMain = require(flatDep).main;
    runnerRoot = flatDep;
  } else if (fileExists(treeDep)) {
    runnerMain = require(treeDep).main;
    runnerRoot = treeDep;
  } else {
    let message = 'Error loading test runner. Post an issue. https://github.com/coderoad/atom-coderoad/issues';
    console.log(message);
    throw message;
  }

  // fix main path for Windows
  let slash = isWindows ? '\\' : '/';
  runnerMain = join.apply(null, runnerMain.split(slash));
  // trim root path to folder
  runnerRoot = runnerRoot.substring(0, runnerRoot.lastIndexOf(slash));

  let pathToMain = join(runnerRoot, runnerMain);

  if (!!require(pathToMain).default) {
    return require(pathToMain).default;
  } else {
    return require(pathToMain);
  }
}
开发者ID:excalliburbd,项目名称:atom-coderoad,代码行数:37,代码来源:config-runner.ts


示例4: packageJson

export default function packageJson(
  pj = null, action: Action
): PackageJson {
  switch (action.type) {

    case SETUP_PACKAGE:
      const pathToPackageJson = join(action.payload.dir, 'package.json');
      return fileExists(pathToPackageJson)
        ? readParse(pathToPackageJson)
        : null;

    default:
      return pj;
  }
}
开发者ID:excalliburbd,项目名称:atom-coderoad,代码行数:15,代码来源:index.ts


示例5: loadRunner

export default function loadRunner(dir: string, name: string) {
  const packagePath = join(dir, 'node_modules', name);
  // no runner installed
  if (!fileExists(packagePath)) {
    return noRunner;
  }
  let runner;
  try {
    const pj = join(packagePath, 'package.json');
    const runnerMain = require(pj).main;
    let pathToMain = resolve(packagePath, runnerMain);
    runner = require(pathToMain);
  } catch (e) {
    console.log(e);
  }
  return runner ? runner.default : noRunner;
}
开发者ID:coderoad,项目名称:builder-coderoad,代码行数:17,代码来源:loadRunner.ts


示例6: packageJson

export default function packageJson(
  pj = null, action: Action
): PackageJson {
  switch (action.type) {

    case 'SETUP_PACKAGE':
      const {dir} = action.payload;
      const pathToPackageJson = join(dir, 'package.json');
      if (fileExists(pathToPackageJson)) {
        return JSON.parse(readFileSync(pathToPackageJson, 'utf8'));
      }
      return null;

    default:
      return pj;
  }
}
开发者ID:lixonics,项目名称:atom-coderoad,代码行数:17,代码来源:index.ts


示例7: join

 folders.forEach(x => {
   current.push(x);
   const folderPath = join(dir, current.join('/'));
   if (!fileExists(folderPath)) {
     mkdirSync(folderPath);
   }
 });
开发者ID:coderoad,项目名称:builder-coderoad,代码行数:7,代码来源:writeFile.ts


示例8: join

      .map(function(name: string) {
        const pathToTutorialPackageJson = join(
          dir, 'node_modules', name, 'package.json'
        );
        // no package.json
        if (!fileExists(pathToTutorialPackageJson)) {
          console.log(
            `Error with ${name}: no package.json file found. ${tutorialError}`
          );
          return {
            name,
            version: 'NOT INSTALLED'
          };
        }

        let tutorialPackageJson = JSON.parse(
          readFileSync(pathToTutorialPackageJson, 'utf8')
        );
        const version = tutorialPackageJson.version;

        return {
          name,
          version,
          latest: !!canUpdateTutorial(name, version)
        };
      }));
开发者ID:lixonics,项目名称:atom-coderoad,代码行数:26,代码来源:check.ts


示例9: Promise

 return new Promise((resolve, reject) => {
   // delete file first, to avoid bug
   if (fileExists(file)) {
     unlink(file);
   }
   // delay necessary since opening a file is slow
   const openTimeout = 200;
   atom.workspace.open(file, options);
   setTimeout(() => resolve(), openTimeout);
 });
开发者ID:lixonics,项目名称:atom-coderoad,代码行数:10,代码来源:file.ts


示例10: isTutorial

export function isTutorial(dir: string, name: string): boolean {
  // has package.json
  const pathToTutorialPackageJson = join(
    dir, 'node_modules', name, 'package.json'
  );
  if (!fileExists(pathToTutorialPackageJson)) {
    console.log(`Error with ${name}: no package.json file found. ${tutorialError}`);
    return false;
  }
  // main path to coderoad.json
  let packageJson = JSON.parse(readFileSync(pathToTutorialPackageJson, 'utf8'));
  if (!packageJson.main && packageJson.main.match(/coderoad.json$/)) {
    console.log(`Error with ${name}: main does not load a coderoad.json file. ${tutorialError}`);
    return false;
  }
  // coderoad.json file exists
  let pathToCoderoadJson = join(
    dir, 'node_modules', name, packageJson.main
  );
  if (!fileExists(pathToCoderoadJson)) {
    console.log(`Error with ${name}: no coderoad.json file. ${tutorialError}`);
    return false;
  };
  if (!packageJson.config || !packageJson.config.runner) {
    console.log(`Error with ${name}: no test runner specified. ${tutorialError}`);
    return false;
  }

  // let currentTutorialVersion: string = packageJson.dependencies[name] || packageJson.devDependencies[name];
  // canUpdateTutorial(name, currentTutorialVersion);

  // let pathToTestRunner = path.join(dir, 'node_modules', packageJson.config.testRunner);
  // // if (!fileExists(pathToTestRunner)) {
  // //   console.log(`Error with ${name}: ${packageJson.config.testRunner} test runner not installed`);
  // //   return false;
  // // }
  return true;
}
开发者ID:lixonics,项目名称:atom-coderoad,代码行数:38,代码来源:is-tutorial.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript node-forge.asn1类代码示例发布时间:2022-05-25
下一篇:
TypeScript node-fetch.Response类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap