本文整理汇总了TypeScript中memory-fs.readFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readFileSync函数的具体用法?TypeScript readFileSync怎么用?TypeScript readFileSync使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readFileSync函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ready
webpackMiddlewarePromise.then(webpackMiddleware => {
fs = webpackMiddleware.devMiddleware.fileSystem
clientManifest = JSON.parse(
fs.readFileSync(resolve('dist/vue-ssr-client-manifest.json')),
)
if (bundle) {
ready({ bundle, clientManifest, fs })
}
})
示例2: String
compiler.run((err: any) => {
if (err) {
throw err;
}
const resultFilename = path.join(destDir, name);
if (fs.existsSync(resultFilename)) {
result = String(fs.readFileSync(resultFilename));
} else {
result = "";
}
});
示例3: reject
compiler.run((err) => {
if (err) {
reject(err);
}
const resultFilename = path.resolve(destDir, name);
if (fs.existsSync(resultFilename)) {
resolve(String(fs.readFileSync(resultFilename)));
} else {
resolve("");
}
});
示例4: next
app.use((ctx, next) => {
if (ctx.method !== 'GET' && ctx.method !== 'HEAD') {
ctx.status = 405;
ctx.length = 0;
ctx.set('Allow', 'GET, HEAD');
next();
return (false);
}
const filePath = ctx.path[ctx.path.length - 1] === '/'
? join(output, ctx.path, 'index.html')
: join(output, ctx.path);
if (!fileSystem.existsSync(filePath)) {
ctx.status = 404;
ctx.length = 0;
next();
return (false);
}
const fileStat = fileSystem.statSync(filePath);
ctx.type = getType(filePath)!;
ctx.lastModified = new Date();
ctx.set('Accept-Ranges', 'bytes');
ctx.set('Cache-Control', 'max-age=0');
// node-fs
if (fileStat instanceof fs.Stats) {
ctx.length = fileStat.size;
}
// memory-fs
else {
ctx.length = Buffer.from(fileSystem.readFileSync(filePath)).length;
}
ctx.body = fileSystem.createReadStream(filePath);
next();
});
示例5: reloadApp
private reloadApp() {
const code = this.vfs.readFileSync('/' + this.bundleFilename).toString('utf8');
this.app = evalCode(code);
}
示例6:
devMiddleware.waitUntilValid(() => {
const indexFile = path.join(webpackConfig.output!.path!, index);
res.end(fs.readFileSync(indexFile));
});