本文整理汇总了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;未经允许,请勿转载。 |
请发表评论