本文整理汇总了TypeScript中fs-extra-promise.readFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readFileSync函数的具体用法?TypeScript readFileSync怎么用?TypeScript readFileSync使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readFileSync函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: hasWebServerDependency
function hasWebServerDependency(targetProjectData: TargetProjectData): boolean {
if (!targetProjectData || !targetProjectData.projectJsonPath) {
return false;
}
let projectJson = fs.readFileSync(targetProjectData.projectJsonPath.fsPath, 'utf8');
projectJson = projectJson.replace(/^\uFEFF/, '');
let projectJsonObject: any;
try {
// TODO: This error should be surfaced to the user. If the JSON can't be parsed
// (maybe due to a syntax error like an extra comma), the user should be notified
// to fix up their project.json.
projectJsonObject = JSON.parse(projectJson);
} catch (error) {
projectJsonObject = null;
}
if (projectJsonObject == null) {
return false;
}
for (var key in projectJsonObject.dependencies) {
if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
return true;
}
}
return false;
}
示例2: formatByTimestamp
function formatByTimestamp() {
const FIVE_MINUTES = 1000 * 60 * 5
const timestampPath = jd('timestamp.txt')
const now = new Date()
if (fsep.existsSync(timestampPath)) {
const oldTimestamp = fsep.readFileSync(timestampPath).toString()
const oldDate = new Date(oldTimestamp)
const difference = now.valueOf() - oldDate.valueOf()
if (difference > FIVE_MINUTES) {
log('Running 5 minute code format')
updateTimestamp()
soFormatDefinitely()
} else {
log(ms(FIVE_MINUTES - difference) + ' to next format')
return
}
}
updateTimestamp()
function updateTimestamp() {
fsep.writeFileSync(timestampPath, now.toISOString())
}
}
示例3: elmxMake
export function elmxMake(inputFile: string, outputFile: string): void {
const elmx = require('elmx')
const elmxFile = fsep.readFileSync(inputFile).toString()
const elmSource = elmx(elmxFile)
fsep.writeFileSync(outputFile, elmSource)
}
示例4: addApiExportedFlag
export function addApiExportedFlag(iterator: ObjectIterator) {
const baseModule = findBaseModule(iterator.modules);
let tsFile = readFileSync(baseModule.originalName, "utf-8");
let exportedFromAnotherModule = parseExportClause(tsFile);
let exportedInBaseModule = (id) => id > baseModule.id && id < iterator.lastId;
iterator.addFlags({ isApiExported: true }, (obj) => {
return obj.flags.isExported &&
(exportedFromAnotherModule.indexOf(obj.name) > -1 ||
exportedInBaseModule(obj.id))
});
}
示例5: hasWebServerDependency
function hasWebServerDependency(projectJsonPath: string) {
let projectJson = fs.readFileSync(projectJsonPath, 'utf8');
let projectJsonObject = JSON.parse(projectJson);
if (projectJsonObject == null) {
return false;
}
for (var key in projectJsonObject.dependencies) {
if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
return true;
}
}
return false;
}