2017-08-29 70 views
0

我们现在开始采购我们的项目,并且作为开源要求,项目中的每个文件都需要在文件顶部包含许可评论。角度生成到特定格式或自定义生成的代码

一旦用户下载了代码,他们可以将更多的组件,指令,管道等添加到项目中。我们希望,当用户在项目目录中运行任何ng命令时,新创建的组件,指令或堆也将在文件顶部使用许可证注释生成。其中所产生的组分它具有下面的代码格式

import { Component, OnInit } from '@angular/core'; 

@Component({ 
    selector: 'app-restaurant', 
    templateUrl: './restaurant.component.html', 
    styleUrls: ['./restaurant.component.scss'] 
}) 
export class RestaurantComponent implements OnInit { 

    constructor() { } 

    ngOnInit() { 
    } 

} 

例如我希望它是这样的。

/* 
* Copyright 2017 shepherd contributors 
* 
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
*  http://www.apache.org/licenses/LICENSE-2.0 
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License. 
*/ 
import { Component, OnInit } from '@angular/core'; 

@Component({ 
    selector: 'app-restaurant', 
    templateUrl: './restaurant.component.html', 
    styleUrls: ['./restaurant.component.scss'] 
}) 
export class RestaurantComponent implements OnInit { 

    constructor() { } 

    ngOnInit() { 
    } 

} 

有没有一种方法可以在目前的角度cli?

+0

为什么你需要这个来源? –

+0

只需添加一些后处理器并在构建中添加一些标头。 –

+0

你必须分叉CLI,它[目前不支持](https://github.com/angular/angular-cli/issues/2377)。 – jonrsharpe

回答