示例#1
0
		.then(_ => promisify(fs.readFile)(OUT_FILE))
示例#2
0
文件: pfs.ts 项目: PKRoma/vscode
export function truncate(path: string, len: number): Promise<void> {
	return promisify(fs.truncate)(path, len);
}
示例#3
0
import SteamCommunity from 'steamcommunity';
import { promisify } from 'util';
import debug from 'debug';
import config from 'config';

const log = debug('TF2Pickup:utils:steam-community');
const steamCommunity = new SteamCommunity();
const login = promisify(steamCommunity.login.bind(steamCommunity));
const username = config.get<string | null>('services.steam.username');
const password = config.get<string | null>('services.steam.password');

export async function setupSteam() {
  if (password === null || username === null) {
    return;
  }

  try {
    await login({
      accountName: username,
      password,
    });

    log('Successfully logged into steam');
  } catch (error) {
    log('Error while logging into steam', { error });
  }
}

export default steamCommunity;
示例#4
0
文件: pfs.ts 项目: PKRoma/vscode
export function lstat(path: string): Promise<fs.Stats> {
	return promisify(fs.lstat)(path);
}
示例#5
0
文件: pfs.ts 项目: PKRoma/vscode
export function unlink(path: string): Promise<void> {
	return promisify(fs.unlink)(path);
}
示例#6
0
import getRes from 'get-res';
import logSymbols from 'log-symbols';
import mem from 'mem';
import makeDir from 'make-dir';
import captureWebsite from 'capture-website';
import viewportList from 'viewport-list';
import filenamify from 'filenamify';
import filenamifyUrl from 'filenamify-url';
import template from 'lodash.template';
import plur from 'plur';
import unusedFilename from 'unused-filename';

// TODO: Move this to `type-fest`
type Mutable<ObjectType> = {-readonly [KeyType in keyof ObjectType]: ObjectType[KeyType]};

const writeFile = promisify(fs.writeFile);

export interface Options {
	readonly delay?: number;
	readonly timeout?: number;
	readonly crop?: boolean;
	readonly css?: string;
	readonly script?: string;
	readonly cookies?: readonly (string | {[key: string]: string})[];
	readonly filename?: string;
	readonly incrementalName?: boolean;
	readonly selector?: string;
	readonly hide?: readonly string[];
	readonly username?: string;
	readonly password?: string;
	readonly scale?: number;
示例#7
0
文件: pfs.ts 项目: PKRoma/vscode
export function exists(path: string): Promise<boolean> {
	return promisify(fs.exists)(path);
}
示例#8
0
'use strict';

import { conn, Product, User } from '../models';
import { promisify } from 'util';
const readFile = promisify(require('fs').readFile);

conn.once('open', () => {
    main().then(() => conn.close());
});

async function main() {
    try {

        let users = JSON.parse(await readFile('./initial_data/userMocks.json', 'utf8'));
        console.log(`Read ${users.length} users.`);
        for (let userData of users) {
            const newUser = new User(userData);
            let user = await newUser.save();
            console.log(`Saved "${user.name}" (${user._id})`);
        }
        console.log('Users loaded!');

        let products = JSON.parse(await readFile('./initial_data/productMocks.json', 'utf8'));
        console.log(`Read ${products.length} products.`);
        for (let productData of products) {
            let newProduct = new Product(productData);
            let product = await newProduct.save();
            console.log(`Saved "${product.name}" (${product._id})`);
        }
        console.log('Products loaded!');
示例#9
0
// tslint:disable:no-console
import * as fs from "fs";
import * as path from "path";
import * as ts from "typescript";
import { promisify } from "util";

import { assert } from "node-opcua-assert";
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
import { ConstructorFunc } from "node-opcua-factory";

import { get_class_tscript_filename, produce_tscript_code } from "./factory_code_generator";

const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);

const fileExists = promisify(fs.exists);
const mkdir = promisify(fs.mkdir);

/**
 * @module opcua.miscellaneous
 * @class Factory
 * @static
 */

function compileTscriptCode(typescriptFilename: string): string {

    const content = fs.readFileSync(typescriptFilename, "ascii");

    const compilerOptions = {
        module: ts.ModuleKind.CommonJS,
        target: ts.ScriptTarget.ES2016,
示例#10
0
文件: write.ts 项目: image-js/core
import { writeFile, writeFileSync } from 'fs';
import { extname } from 'path';
import { promisify } from 'util';

import { Image } from '../Image';

import {
  encode,
  ImageFormat,
  IEncodeOptionsPng,
  IEncodeOptionsJpeg
} from './encode';

const writeFilePromise = promisify(writeFile);

/**
 * Write an image to the disk.
 * The file format is determined automatically from the file's extension.
 * If the extension is not supported, an error will be thrown.
 */
export async function write(path: string, image: Image): Promise<void>;
/**
 * Write an image to the disk as PNG.
 * When the `png` format is specified, the file's extension doesn't matter.
 */
export async function write(
  path: string,
  image: Image,
  options: IEncodeOptionsPng
): Promise<void>;
/**