當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript config.getWorkspacePath函數代碼示例

本文整理匯總了TypeScript中@schematics/angular/utility/config.getWorkspacePath函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getWorkspacePath函數的具體用法?TypeScript getWorkspacePath怎麽用?TypeScript getWorkspacePath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getWorkspacePath函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: return

 return (host: Tree, context: SchematicContext) => {
   const workspacePath = getWorkspacePath(host);
   if (!workspacePath) {
     return;
   }
   host.create(
       `${workspacePath}.bak`, '// This is a backup file of the original angular.json. ' +
           'This file is needed in case you want to revert to the workflow without Bazel.\n\n' +
           host.read(workspacePath));
 };
開發者ID:alxhub,項目名稱:angular,代碼行數:10,代碼來源:index.ts

示例2: addResetCss

export function addResetCss(host: Tree): boolean {
    const config = getWorkspace(host);
    const project = config.projects[config.defaultProject] as WorkspaceProject<ProjectType.Application>;
    let addPackage;

    const styleExts = ['scss', 'sass', 'css', 'less', 'styl'];
    const styleExt = styleExts.find(ext => host.exists(path.posix.join(project.sourceRoot, `styles.${ext}`)));
    if (!styleExt) {
        return false;
    }
    const stylesFile = path.posix.join(project.sourceRoot, `styles.${styleExt}`);

    switch (styleExt) {
    case 'sass':
    case 'scss':
        let content = host.read(stylesFile).toString();
        if (content.indexOf(`~minireset.css/minireset`) === -1) {
            content = scssImport + content;
            host.overwrite(stylesFile, content);
            addPackage = resetPackage;
        }
        break;
    case 'css':
    case 'less':
    case 'styl':
        if (!project.architect ||
            !project.architect.build ||
            project.projectType !== ProjectType.Application) {
            return false;
        }
        if (project.architect.build.options.styles) {
            project.architect.build.options.styles =
                [cssImport, ...project.architect.build.options.styles];
        } else {
            project.architect.build.options.styles = [cssImport];
        }
        host.overwrite(getWorkspacePath(host), JSON.stringify(config, null, 2));
        addPackage = resetPackage;
        break;
    default:
        break;
    }

    if (addPackage) {
        const targetFile = 'package.json';
        if (host.exists(targetFile)) {
            const pkgJson = JSON.parse(host.read(targetFile).toString());
            pkgJson.dependencies = Object.assign({}, addPackage, pkgJson.dependencies);
            host.overwrite(targetFile, JSON.stringify(pkgJson, null, 2) + '\n');
            return true;
        }
    }
    return false;
}
開發者ID:IgniteUI,項目名稱:igniteui-angular,代碼行數:54,代碼來源:add-normalize.ts


注:本文中的@schematics/angular/utility/config.getWorkspacePath函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。