@@ -60,9 +60,71 @@ var uglify = require('gulp-uglify');
6060var bump = require ( 'gulp-bump' ) ;
6161var gulpif = require ( 'gulp-if' ) ;
6262var argv = require ( 'yargs' ) . argv ;
63+ var path = require ( 'path' ) ;
6364
6465var pkg = require ( './package.json' ) ;
6566
67+ gulp . task ( 'license' , function ( ) {
68+
69+ var clean = argv . clean ;
70+ if ( ! clean ) clean = false ;
71+
72+ return gulp . src ( [ 'src/**/*.js' ] )
73+ . pipe ( prependLicense ( clean ) ) ;
74+
75+ } ) ;
76+
77+ function prependLicense ( clean ) {
78+
79+ var license = `/**
80+ * Copyright 2016 PT Inovação e Sistemas SA
81+ * Copyright 2016 INESC-ID
82+ * Copyright 2016 QUOBIS NETWORKS SL
83+ * Copyright 2016 FRAUNHOFER-GESELLSCHAFT ZUR FOERDERUNG DER ANGEWANDTEN FORSCHUNG E.V
84+ * Copyright 2016 ORANGE SA
85+ * Copyright 2016 Deutsche Telekom AG
86+ * Copyright 2016 Apizee
87+ * Copyright 2016 TECHNISCHE UNIVERSITAT BERLIN
88+ *
89+ * Licensed under the Apache License, Version 2.0 (the "License");
90+ * you may not use this file except in compliance with the License.
91+ * You may obtain a copy of the License at
92+ *
93+ * http://www.apache.org/licenses/LICENSE-2.0
94+ *
95+ * Unless required by applicable law or agreed to in writing, software
96+ * distributed under the License is distributed on an "AS IS" BASIS,
97+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
98+ * See the License for the specific language governing permissions and
99+ * limitations under the License.
100+ **/
101+ ` ;
102+
103+ return through . obj ( function ( file , enc , cb ) {
104+
105+ if ( file . isNull ( ) ) {
106+ return cb ( new Error ( 'Fil is null' ) ) ;
107+ }
108+
109+ if ( file . isStream ( ) ) {
110+ return cb ( new Error ( 'Streaming not supported' ) ) ;
111+ }
112+
113+ var dest = path . dirname ( file . path ) ;
114+
115+ return gulp . src ( file . path )
116+ . pipe ( replace ( license , '' ) )
117+ . pipe ( gulpif ( ! clean , insert . prepend ( license ) ) )
118+ . pipe ( gulp . dest ( dest ) )
119+ . on ( 'end' , function ( ) {
120+ cb ( ) ;
121+ } ) ;
122+
123+ } ) ;
124+
125+ }
126+
127+
66128gulp . task ( 'runtime' , function ( ) {
67129
68130 var compact = argv . compact ;
0 commit comments