當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra.emptyDirSync函數代碼示例

本文整理匯總了TypeScript中fs-extra.emptyDirSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript emptyDirSync函數的具體用法?TypeScript emptyDirSync怎麽用?TypeScript emptyDirSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了emptyDirSync函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: assertDirsEqual

function assertDirsEqual(actual: string, expected: string, basedir = actual) {
  if (process.env['UPDATE_POLYMER_CLI_GOLDENS']) {
    fsExtra.emptyDirSync(expected);
    fsExtra.copySync(actual, expected);
    throw new Error('Goldens updated, test failing for your saftey.');
  }

  const actualNames = fs.readdirSync(actual).sort();
  const expectedNames = fs.readdirSync(expected).sort();
  assert.deepEqual(
      actualNames,
      expectedNames,
      `expected files in directory ${path.relative(basedir, actual)}`);
  for (const fn of actualNames) {
    const subActual = path.join(actual, fn);
    const subExpected = path.join(expected, fn);
    const stat = fs.statSync(subActual);
    if (stat.isDirectory()) {
      assertDirsEqual(subActual, subExpected, basedir);
    } else {
      const actualContents = fs.readFileSync(subActual, 'utf-8').trim();
      const expectedContents = fs.readFileSync(subExpected, 'utf-8').trim();
      assert.deepEqual(
          actualContents,
          expectedContents,
          `expected contents of ${path.relative(basedir, subActual)}`);
    }
  }
}
開發者ID:poehlmann,項目名稱:EvaluacionDiferencialDeLaMemoria,代碼行數:29,代碼來源:build_test.ts

示例2: clear

  /**
   * 清空 DEST 目錄
   */
  clear () {
    let { isClear } = this.options
    if (!isClear) return

    Global.clear()
    xcxNext.clear()
    xcxNodeCache.clear()
    fs.emptyDirSync(config.getPath('dest'))
  }
開發者ID:bbxyard,項目名稱:bbxyard,代碼行數:12,代碼來源:Xcx.ts

示例3: cleanupOldScreenshots

function* cleanupOldScreenshots() {
  console.log("Cleaning up screenshots directory");
  try {
    fsa.emptyDirSync(SCREENSHOTS_DIRECTORY);
    fsa.rmdirSync(SCREENSHOTS_DIRECTORY);
  } catch(e) {
    console.warn(`Cannot cleaup directory ${SCREENSHOTS_DIRECTORY}: `, e);
  }

  fsa.mkdirpSync(SCREENSHOTS_DIRECTORY);
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:11,代碼來源:screenshots.ts

示例4: build

 .then((previousFileSizes: Object) => {
   // Remove all content but keep the directory so that
   // if you're in it, you don't end up in Trash
   fs.emptyDirSync(paths.appBuild);
   // Merge with the public folder
   fs.copySync(paths.appPublic, paths.appBuild, {
     dereference: true,
     filter: file => file !== paths.appHtml,
   });
   // Start the webpack build
   return build(previousFileSizes);
 })
開發者ID:heydoctor,項目名稱:medpack,代碼行數:12,代碼來源:build.ts

示例5: Promise

  return new Promise((resolve, reject) => {
    const logger = new Logger('clean');

    try {
      Logger.debug(`[Clean] clean: cleaning ${context.buildDir}`);

      emptyDirSync(context.buildDir);
      logger.finish();

    } catch (ex) {
      reject(logger.fail(new BuildError(`Failed to clean directory ${context.buildDir} - ${ex.message}`)));
    }
    resolve();
  });
開發者ID:Kode-Kitchen,項目名稱:ionic-app-scripts,代碼行數:14,代碼來源:clean.ts

示例6:

testLib.addTest('mktemp', assert => {
    const TEST_DIR = `${testLib.tempDir()}/vfs-util-test`;
    const ITER_COUNT = 10;

    fs_extra.emptyDirSync(TEST_DIR);
    var fs = new node_vfs.FileVFS(TEST_DIR);
    var count = 0;

    return asyncutil.until(() => {
        ++count;
        return vfs_util
            .mktemp(fs, '/', 'tmp.XXX')
            .then((path: string) => {
                assert.ok(path.match(/\/tmp.[a-z]{3}/) !== null);
            })
            .then(() => count > ITER_COUNT);
    });
});
開發者ID:robertknight,項目名稱:passcards,代碼行數:18,代碼來源:util_test.ts

示例7: catch

connection.onInitialize((params: InitializeParams): InitializeResult => {
  console.log('paperclip language server initialized');
  const initializationOptions = params.initializationOptions;

  workspacePath = params.rootPath;
  vls.initialize(workspacePath, initializationOptions.devToolsPort);

  documents.onDidClose(e => {
    vls.removeDocument(e.document);
  });
  connection.onShutdown(() => {
    vls.dispose();
  });

  try {
    fsa.emptyDirSync(TMP_DIRECTORY);
  } catch(e) {

  }

  try {
    fsa.mkdirpSync(TMP_DIRECTORY);
  } catch(e) {
    
  }

  const capabilities = {
    // Tell the client that the server works in FULL text document sync mode
    textDocumentSync: documents.syncKind,
    completionProvider: { resolveProvider: true, triggerCharacters: ['.', ':', '<', '"', '/', '@', '*'] },
    signatureHelpProvider: { triggerCharacters: ['('] },
    documentFormattingProvider: true,
    hoverProvider: true,
    documentHighlightProvider: true,
    documentSymbolProvider: true,
    definitionProvider: true,
    referencesProvider: true,
    colorProvider: true
  };

  return { capabilities };
});
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:42,代碼來源:pcServerMain.ts

示例8: function

import * as YAML from 'yamljs';
import * as fs from 'fs-extra';
import * as path from 'path';

// First Copy the latest docs into the source directory
fs.emptyDirSync('source/');
fs.removeSync('pre-source/docs-production/.vscode/')
fs.copySync('pre-source/docs-production', 'source');


var _versions = YAML.parse(fs.readFileSync('./_config.yml', "utf8")).versions;
var versions: Array<string> = _versions.filter(e => e !== 'latest')
for (let version of versions) {
  console.log("Preparing Version: " + version);
  fs.copySync('pre-source/docs-' + version, 'source/' + version);
}

// Escape code blocks in the markdown
enumerate_child_files_recursive('source/', function (err, results) {
  if (err) throw err;
  for (let result of results) {
    var is_md = new RegExp(".md");
    if (is_md.test(result)) {
      fs.readFile(result, 'utf8', function (err, data) {
        if (err) {
          return console.log(err);
        }
        var backtick_positions = find(data, "```"); //find positions of backticks

        for (var i = 0, backtick_positions_1 = backtick_positions; i < backtick_positions_1.length; i++) {
          var backtick_position = backtick_positions_1[i];
開發者ID:georgeedwards,項目名稱:docs,代碼行數:31,代碼來源:build.ts

示例9:

fs.ensureFileSync(path);
fs.ensureLink(path).then(() => {
	// stub
});
fs.ensureLink(path, errorCallback);
fs.ensureLinkSync(path);
fs.ensureSymlink(path).then(() => {
	// stub
});
fs.ensureSymlink(path, errorCallback);
fs.ensureSymlinkSync(path);
fs.emptyDir(path).then(() => {
	// stub
});
fs.emptyDir(path, errorCallback);
fs.emptyDirSync(path);
fs.pathExists(path).then((_exist: boolean) => {
	// stub
});
fs.pathExists(path, (_err: Error, _exists: boolean) => { });
const x: boolean = fs.pathExistsSync(path);

fs.rename(src, dest, errorCallback);
fs.renameSync(src, dest);
fs.truncate(path, len, errorCallback);
fs.truncateSync(path, len);
fs.chown(path, uid, gid, errorCallback);
fs.chownSync(path, uid, gid);
fs.fchown(fd, uid, gid, errorCallback);
fs.fchownSync(fd, uid, gid);
fs.lchown(path, uid, gid, errorCallback);
開發者ID:gilamran,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:fs-extra-tests.ts

示例10: ok_all_tests

import {Setting, Ids}  from './../lib/setting';
import * as fs from 'fs-extra';
import * as path from 'path';
import {Model} from './../lib/model';
import * as _ from 'underscore';
import { Tuls as $t} from './test-utils';

import {CmdUtils} from './../lib/cmd-utils';

import * as child_process from 'child_process';

var assert = chai.assert;

let indir = path.join(Setting.test_items_dir);
let outdir = path.join(Setting.test_out_dir);
fs.emptyDirSync(outdir);
let firststep = () => {
  Setting.reset();
  Setting.postinit();
  Setting.mp_console = false;
};
//Init
Setting.postinit();
Setting.mp_console = false;

function ok_all_tests(ppath: string) {
  let _indir = path.join(indir, ppath);
  let _outdir = path.join(outdir, ppath);
  describe('check ' + ppath, () => {
    it('should be ok', () => {
      firststep();
開發者ID:do5,項目名稱:mcgen,代碼行數:31,代碼來源:test.ts


注:本文中的fs-extra.emptyDirSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。