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

TypeScript denodeify类代码示例

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

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



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

示例1: createTsSourceFile

export function createTsSourceFile(fileName: string): Promise<ts.SourceFile> {
  const readFile = denodeify(fs.readFile);
  return readFile(fileName, 'utf8')
    .then((contents: string) => {
      return ts.createSourceFile(fileName, contents, ts.ScriptTarget.ES6, true);
    });
}
开发者ID:AppasThirdLeftFoot,项目名称:angular-cli,代码行数:7,代码来源:get-dependent-files.ts


示例2: switch

 .then(doc => {
     switch (doc.type) {
         case 'apib':
             return denodeify(apib2swagger.convert)(doc.body).then(r => r['swagger'])
         default:
             return JSON.parse(doc.body)
     }
 })
开发者ID:designing-experiences,项目名称:webconsole,代码行数:8,代码来源:index.ts


示例3: function

  run: function(commandOptions: any) {
    const ui = this.ui;
    let promise: Promise<any>;

    // declared here so that tests can stub exec
    const execPromise = denodeify(exec);

    if (/.+/.test(commandOptions.ghToken) && /\w+/.test(commandOptions.ghUsername)) {
      promise = Promise.resolve({
        ghToken: commandOptions.ghToken,
        ghUsername: commandOptions.ghUsername
      });
    } else {
      ui.writeLine();
      ui.writeLine(oneLine`
        In order to deploy this project via GitHub Pages, we must first create a repository for it.
      `);
      ui.writeLine(oneLine`
        It\'s safer to use a token than to use a password so you will need to create one
      `);
      ui.writeLine('Go to the following page and click "Generate new token".');
      ui.writeLine('https://github.com/settings/tokens\n');
      ui.writeLine('Choose "public_repo" as scope and then click "Generate token".\n');
      promise = ui.prompt([
        {
          name: 'ghToken',
          type: 'input',
          message: oneLine`
            Please enter GitHub token you just created
            (used only once to create the repo):
          `,
          validate: function(token: string) {
            return /.+/.test(token);
          }
        }, {
          name: 'ghUsername',
          type: 'input',
          message: 'and your GitHub user name:',
          validate: function(userName: string) {
            return /\w+/.test(userName);
          }
        }]);
    }

    return promise
      .then((answers) => {
      return new Promise(function(resolve, reject) {
        const postData = JSON.stringify({
          'name': commandOptions.projectName
        });

        const req = https.request({
          hostname: 'api.github.com',
          port: 443,
          path: '/user/repos',
          method: 'POST',
          headers: {
            'Authorization': `token ${answers.ghToken}`,
            'Content-Type': 'application/json',
            'Content-Length': postData.length,
            'User-Agent': 'angular-cli-github-pages'
          }
        });

        req.on('response', function(response: any) {
          if (response.statusCode === 201) {
            resolve(execPromise(oneLine`
              git remote add origin 
              [email protected]:${answers.ghUsername}/${commandOptions.projectName}.git
            `));
          } else {
            reject(new SilentError(oneLine`
              Failed to create GitHub repo. Error: ${response.statusCode} ${response.statusMessage}
            `));
          }
        });

        req.write(postData);
        req.end();
      });
    });
  }
开发者ID:Meligy,项目名称:angular-cli,代码行数:82,代码来源:create-github-repo.ts


示例4: denodeify

import {Option} from '../../server/src/Option';
import * as denodeify from 'denodeify';
import {exec as execNode, ExecOptions} from 'child_process';

type Stdout = string;
type Stderr = string;
type ExecResult = [ Stdout, Stderr ];
export const exec: (command: string, options: ExecOptions) => Promise<ExecResult> = (
    denodeify(execNode, (err, stdout, stderr) => [err, [stdout, stderr]])
);
export type StringDictionary<T> = { [key: string]: T };
export const getInStringDictionary = <T>(stringDictionary: StringDictionary<T>, key: number): T | undefined => stringDictionary[key]
export const getInArray = <T>(array: T[], index: number): T | undefined => array[index]
export const OptionHelpers = {
    fromNullable<T>(t: T | null | undefined): Option<T> { return Option(t as T) },
    arrayGet<T>(array: T[], index: number): Option<T> {
        return OptionHelpers.fromNullable(getInArray(array, index))
    },
    stringMatch(str: string, matcher: RegExp): Option<RegExpMatchArray> {
        return OptionHelpers.fromNullable(str.match(matcher))
    },
}
export const stringify = (json: any) => JSON.stringify(json, null, '    ');
export const writePromise = (promise: Promise<string>): Promise<void> => (
    promise.then(
        output => { process.stdout.write(output) },
        error => {
            process.stderr.write(error.stack)
            process.exit(1)
        },
    )
开发者ID:OliverJAsh,项目名称:samefourchords.com,代码行数:31,代码来源:utils.ts


示例5: denodeify

"use strict";

import * as fs from 'fs-extra';
import * as denodeify from 'denodeify';

import {CompilableContent, ICompilableContent} from './CompilableContent';
import {error} from './Logger';

var fsreadfile = denodeify(fs.readFile);

/**
 * Doc wraps up all occurances of markdown documents inside the styleguide.
 */
export class Doc extends CompilableContent {
  load():Promise<ICompilableContent> {
    return super.load()
    .then((doc) => {
      this.compiled = this.render();
      return this;
    })
    .catch(e => {
      error("Doc.load", e);
      console.log(e.stack);
      throw(e);
    });
  }

  static create(path: string, name: string): ICompilableContent {
    var doc:Doc = new Doc(path, name);
    doc.renderer = this.renderer;
    return doc;
开发者ID:janpersiel,项目名称:stylegen,代码行数:31,代码来源:Doc.ts


示例6: denodeify

import {StructureReader} from './StructureReader';
import {StructureWriter} from './StructureWriter';
import {Node} from './Node';
import {ComponentList} from './ComponentList';
import {IRenderer, IRendererOptions} from './Renderer';
import {IPageConfig} from './Page';
import {LinkRegistry} from './LinkRegistry';

import {Doc} from './Doc';
import {Partial} from './Partial';
import {View} from './View';

import {MarkdownRenderer} from './MarkdownRenderer';
import {HandlebarsRenderer} from './HandlebarsRenderer';

var fsensuredir = denodeify(fs.ensureDir);
var fscopy = denodeify(fs.copy);
var outputfile = denodeify(fs.outputFile);

var flatten = (list) => list.reduce(
  (a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
);

interface IStyleguideOptions {
  configPath?: string;
  target?: string;
  cwd?: string;
}

interface IAssetCopyConfig {
  src?: string;
开发者ID:janpersiel,项目名称:stylegen,代码行数:31,代码来源:Styleguide.ts


示例7: denodeify

import * as fs from 'fs-extra';
import * as path from 'path';
import * as slug from 'slug';
import * as denodeify from 'denodeify';

import {Doc} from './Doc';
import {View} from './View';
import {Styleguide} from './Styleguide';
import {IRenderer} from './Renderer';
import {IPageLayoutContext} from './PageLayout';
import {PlainComponentList, IRelatedComponentFiles} from './PlainComponentList';
import {ICompilableContent} from './CompilableContent';
import {warn, error} from './Logger';

var fsoutputfile = denodeify(fs.outputFile);

export interface IPageConfig {
  id?: string;
  label?: string;
  slug?: string;
  type?: string;
  content?: any;
  children?: Page[];
  styleguide?: Styleguide;
  mdRenderer?: IRenderer;
  target?: string;
  preflight?: string;
}

export interface IPageTemplateConfig {
开发者ID:janpersiel,项目名称:stylegen,代码行数:30,代码来源:Page.ts


示例8: read

import { assign } from 'lodash';
import * as _read from 'read';
import * as fs from 'fs';
import * as path from 'path';
import { WebApi, getBasicHandler } from 'vso-node-api/WebApi';
import { IGalleryApi, IQGalleryApi } from 'vso-node-api/GalleryApi';
import * as denodeify from 'denodeify';

const readFile = denodeify<string, string, string>(fs.readFile);

export function fatal<T>(message: any, ...args: any[]): Promise<T> {
	if (message instanceof Error) {
		if (/^cancell?ed$/i.test(message.message)) {
			return;
		}

		message = message.message;
	}

	console.error('Error:', message, ...args);
	process.exit(1);
	return Promise.resolve<T>(null);
}

export function catchFatal<T>(promise: Promise<T>): Promise<T> {
	return promise.catch<T>(fatal);
}

const __read = denodeify<_read.Options,string>(_read);
export function read(prompt: string, options: _read.Options = {}): Promise<string> {
	return __read(assign({ prompt }, options));
开发者ID:rid9,项目名称:vscode-vsce,代码行数:31,代码来源:util.ts


示例9: require

import * as denodeify from 'denodeify';

const SilentError = require('silent-error');
const PortFinder = require('portfinder');
const getPort = denodeify<{host: string, port: number}, number>(PortFinder.getPort);

export function checkPort(port: number, host: string, basePort = 49152): Promise<number> {
  PortFinder.basePort = basePort;
  return getPort({ port, host })
    .then(foundPort => {

      // If the port isn't available and we weren't looking for any port, throw error.
      if (port !== foundPort && port !== 0) {
        throw new SilentError(
          `Port ${port} is already in use. Use '--port' to specify a different port.`
        );
      }

      // Otherwise, our found port is good.
      return foundPort;
    });
}
开发者ID:3L4CKD4RK,项目名称:angular-cli,代码行数:22,代码来源:check-port.ts


示例10: denodeify

"use strict";

import * as path from 'path';
import * as fs from 'fs-extra';
import * as denodeify from 'denodeify';

import {warn} from './Logger';
import {Config} from './Config';
import {Styleguide} from './Styleguide';
import {IComponentConfig} from './Component';
import {Component} from './Component';
import {Partial} from './Partial';

var fsstat = denodeify(fs.stat);
var fsreaddir = denodeify(fs.readdir);


/** options, that can be handed to nodes */
export interface INodeOptions {
  namespace?: string;
  styleguide?: Styleguide;
  componentDocs?: string;
}

/**
 * a Node represents a folder-node inside of the configured component paths.
 * It may have a Component (1-to-1), but maybe it is just a container for
 * child nodes, that are components.
 *
 * TODO: i guess nodes may also be pages
 */
开发者ID:janpersiel,项目名称:stylegen,代码行数:31,代码来源:Node.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript deprecate类代码示例发布时间:2022-05-28
下一篇:
TypeScript del类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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