本文整理匯總了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));
});