本文整理汇总了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);
});
示例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);
}
});
示例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);
示例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);
}
}
}
};
示例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) {
}
});
示例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;
}
}
示例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) {
}
});
示例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));
}
示例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);
}
};
示例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);
});