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