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


TypeScript fs.unlinkSync函數代碼示例

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


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

示例1: reject

 fs.stat(filePath, (error, stats) => {
   if (error) {
     (error as any).msg = 'Error: Got error ' + error + ' from ' + fileUrl;
     return reject(error);
   }
   if (stats.size != resContentLength) {
     (error as any).msg = 'Error: corrupt download for ' + fileName +
         '. Please re-run webdriver-manager update';
     fs.unlinkSync(filePath);
     reject(error);
   }
   if (callback) {
     callback(binary, outputDir, fileName);
   }
   resolve(true);
 });
開發者ID:elgohr,項目名稱:webdriver-manager,代碼行數:16,代碼來源:downloader.ts

示例2: function

 fs.stat(filePath, function(err, stats) {
   if (err) {
     logger.error('Error: Got error ' + err + ' from ' + fileUrl);
     return;
   }
   if (stats.size != contentLength) {
     logger.error(
         'Error: corrupt download for ' + fileName +
         '. Please re-run webdriver-manager update');
     fs.unlinkSync(filePath);
     return;
   }
   if (callback) {
     callback(filePath);
   }
 });
開發者ID:hu19891110,項目名稱:webdriver-manager,代碼行數:16,代碼來源:downloader.ts

示例3: testFile

		testFile('config', 'config.json').then(res => {
			fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "bar" }');

			let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile);
			watcher.getConfig(); // ensure we are in sync

			watcher.onDidUpdateConfiguration(event => {
				assert.ok(event);

				watcher.dispose();

				res.cleanUp().then(done, done);
			});

			fs.unlinkSync(res.testFile);
		}, done);
開發者ID:AllureFer,項目名稱:vscode,代碼行數:16,代碼來源:config.test.ts

示例4: rmDir

export function rmDir(dirPath) {
    let files = [];
    files = fs.readdirSync(dirPath);
    if (files.length > 0) {
        for (let i = 0; i < files.length; i++) {
            let filePath = dirPath + '/' + files[i];
            if (fs.statSync(filePath).isFile()) {
                if (filePath.indexOf('gitkeep') === -1) {
                    fs.unlinkSync(filePath);
                }
            } else {
                rmDir(filePath);
            }
        }
    }
};
開發者ID:lowkay,項目名稱:docscript,代碼行數:16,代碼來源:utils.ts

示例5: beforeAll

    beforeAll(async () => {
      proc = spawnProcess('node', ['dist/spec/server/http_server.js']);
      log.debug('http-server: ' + proc.pid);
      await new Promise((resolve, _) => {
        setTimeout(resolve, 3000);
      });

      try {
        fs.mkdirSync(tmpDir);
      } catch (err) {
      }
      try {
        fs.unlinkSync(fileName);
      } catch (err) {
      }
    });
開發者ID:angular,項目名稱:webdriver-manager,代碼行數:16,代碼來源:http_utils.spec-int.ts

示例6: removeFiles

export function removeFiles(outDir: string, fileRegexes: RegExp[]): string {
  try {
    const existFiles = fs.readdirSync(outDir);
    const removedFiles: string[] = [];
    for (const fileRegex of fileRegexes) {
      for (const existFile of existFiles) {
        if (existFile.match(fileRegex)) {
          removedFiles.push(existFile);
          fs.unlinkSync(path.resolve(outDir, existFile));
        }
      }
    }
    return (removedFiles.sort()).join('\n');
  } catch (_) {
    return null;
  }
}
開發者ID:angular,項目名稱:webdriver-manager,代碼行數:17,代碼來源:file_utils.ts

示例7: beforeAll

  beforeAll((done) => {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
    httpProc = spawnProcess('node', ['dist/spec/server/http_server.js']);
    log.debug('http-server: ' + httpProc.pid);
    proxyProc = spawnProcess('node', ['dist/spec/server/proxy_server.js']);
    log.debug('proxy-server: ' + proxyProc.pid);
    setTimeout(done, 3000);

    try {
      fs.mkdirSync(tmpDir);
    } catch (err) {
    }
    try {
      fs.unlinkSync(fileName);
    } catch (err) {
    }
  });
開發者ID:angular,項目名稱:webdriver-manager,代碼行數:17,代碼來源:http_utils.spec-proxy.ts

示例8: start

 static start(tag: string) {
   let unixPath = util.format('/tmp/lightsword-%s.sock', tag);
   if (fs.existsSync(unixPath)) fs.unlinkSync(unixPath);
   
   let server = net.createServer(async (client) => {
     let data = await client.readAsync();
     let msg = '';
     let mem: { rss: number, heapTotal: number, heapUsed: number };
     
     switch(data[0]) {
       case COMMAND.STOP:
         msg = `${path.basename(process.argv[1])}d (PID: ${process.pid}) is going to quit.`;
         await client.writeAsync(new Buffer(msg));
         process.exit(0);
         break;
       case COMMAND.RESTART:
         let cp = child.spawn(process.argv[1], process.argv.skip(2).toArray(), { detached: true, stdio: 'ignore', env: process.env, cwd: process.cwd() });
         cp.unref();
         process.exit(0);
         break;
       case COMMAND.STATUS:
         mem = process.memoryUsage();
         msg = `${path.basename(process.argv[1])}d (PID: ${process.pid}) is running.`;
         msg = util.format('%s\nHeap total: %sMB, heap used: %sMB, rss: %sMB', msg, (mem.heapTotal / 1024 / 1024).toPrecision(2), (mem.heapUsed / 1024 / 1024).toPrecision(2), (mem.rss / 1024 / 1024).toPrecision(2));
         await client.writeAsync(new Buffer(msg));
         client.dispose();
         break;
       case COMMAND.STATUSJSON:
         mem = process.memoryUsage();
         let obj = {
           process: path.basename(process.argv[1]) + 'd',
           pid: process.pid,
           heapTotal: mem.heapTotal,
           heapUsed: mem.heapUsed,
           rss: mem.rss
         };
         await client.writeAsync(new Buffer(JSON.stringify(obj)));
         client.dispose();
         break;
     }
   });
   
   server.listen(unixPath);
   server.on('error', (err) => console.error(err.message));
 }
開發者ID:52M,項目名稱:LightSword,代碼行數:45,代碼來源:ipc.ts

示例9: Generate

 public static Generate(templatePath: string, destPath: string, data: any, fileName: string, suffix?: string): void {
     try {
         let source = fs.readFileSync(templatePath, 'utf-8');
         let template = Handlebars.compile(source);
         let view = { data: data, Name: fileName };
         let result = template(view);
         if (!fs.existsSync(destPath)) {
             fs.mkdirSync(destPath);
         }
         let dfName = join(destPath, fileName + suffix);
         if (fs.existsSync(dfName)) {
             fs.unlinkSync(dfName);
         }
         fs.writeFileSync(dfName, result);
     } catch (ex) {
         util.log(ex);
     }
 };
開發者ID:mission-io,項目名稱:mission.api,代碼行數:18,代碼來源:generator.ts

示例10: it

    it('loads plugins', async () => {
      const { calls, reset } = mockConsole(Infinity);
      const output = 'plugins-on.png';

      await run(
        'read',
        makePath(__dirname, './images/tiny-qr.png'),
        '--output',
        output,
        '-v',
        '-p',
        '@jimp/plugin-circle'
      );

      reset();
      calls.length.should.be.exactly(4);
      fs.unlinkSync(output);
    });
開發者ID:oliver-moran,項目名稱:jimp,代碼行數:18,代碼來源:index.test.ts


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