本文整理匯總了TypeScript中fs-extra-promise.readJsonSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript readJsonSync函數的具體用法?TypeScript readJsonSync怎麽用?TypeScript readJsonSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了readJsonSync函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: toMarkdown
export function toMarkdown(typeDocJsonFile: string): string {
const source = readJsonSync(typeDocJsonFile);
const markdown = new Markdown(source);
return markdown.getText();
}
示例2: getTypes
function getTypes() {
// it looks like types need to be converted to an absolute path for ForkTsCheckerWebpackPlugin
// we need to do this for "../dist-i18n" mostly
if (project.ws.tsconfigPath) {
const config = readJsonSync(project.ws.tsconfigPath);
if (config.compilerOptions && config.compilerOptions.types) {
return config.compilerOptions.types.map((type: string) =>
type.startsWith('.')
? join(dirname(project.ws.tsconfigPath!), type)
: type
);
} else {
return [];
}
} else {
return [];
}
}
示例3: readJsonSync
async: false,
checkSyntacticErrors: true,
// `watch` is optional, but docs say it improves performance (less stat calls)
watch: [project.ws.srcDir, project.ws.testsDir]
});
export const devtool = 'inline-source-map';
export const devtoolProduction = 'source-map';
export const externalsSpa = project.ws.externals ? [project.ws.externals] : [];
// dirty fix until https://github.com/liady/webpack-node-externals/issues/39 is solved
let isWorkspace = false;
try {
const pkg = readJsonSync(join(process.cwd(), '..', '..', 'package.json'));
isWorkspace = !!pkg.workspaces;
} catch (err) {
// no workspace
}
export const externalsNode = [
// require json files with nodes built-in require logic
function(_context: any, request: any, callback: any) {
if (/\.json$/.test(request)) {
callback(null, 'commonjs ' + request);
} else {
callback();
}
},
// in order to ignore all modules in node_modules folder
示例4: readJsonSync
import { join, basename } from 'path';
import chalk from 'chalk';
import { existsSync, readJsonSync } from 'fs-extra-promise';
import {
parseJsonConfigFileContent,
readConfigFile,
sys,
CompilerOptions
} from 'typescript';
const { yellow } = chalk;
const unvalidatedProject = readJsonSync(join(process.cwd(), 'package.json'));
export const TYPE = {
SPA: 'spa' as 'spa',
NODE: 'node' as 'node',
BROWSER: 'browser' as 'browser'
};
const TYPES = [TYPE.SPA, TYPE.NODE, TYPE.BROWSER];
/**
* Our i18n settings. Only needed for translated projects.
*/
export interface I18nConfig {
/**
* The locales your project supports. A locale consists of a language code (expressed
* by two lower case characters), a `_` and a country code (expressed by two upper case
* characters). E.g. valid locales are `'en_GB'`, `'de_AT'`, `'it_IT'` and so on.
*
示例5: join
import { readJsonSync, writeFileAsync, readFileAsync } from 'fs-extra-promise';
import { join, relative } from 'path';
import chalk from 'chalk';
import { CLIEngine } from 'eslint';
import codeFrame from 'babel-code-frame';
import { sourceFilePatterns } from '../project';
const { dim, red } = chalk;
// relative from dist/index.js
const configPath = join(__dirname, '..', '.eslintrc.json');
const config = readJsonSync(configPath);
// learn about the caveats of `config.fix = true` here: https://github.com/eslint/eslint/issues/9147
config.fix = true;
const engine = new CLIEngine(config);
interface Message {
ruleId: string;
severity: 0 | 1 | 2;
message: string;
line: number;
column: number;
nodeType: string;
source: string;
endLine: number;
endColumn: number;
}
interface Result {
filePath: string;
messages: Array<Message>;