-
Notifications
You must be signed in to change notification settings - Fork 0
/
setlicense.mjs
59 lines (54 loc) · 2.31 KB
/
setlicense.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*!
=========================================================
* © 2024 Ronan LE MEILLAT for SCTG Development
=========================================================
* RUN WITH
* npx gulp -f setlicense.mjs licenses
*/
import fs from 'fs'
import gulp from 'gulp'
import gap from 'gulp-append-prepend'
import gulpif from 'gulp-if'
function checkCopyright(file) {
const content = fs.readFileSync(file.path, 'utf8')
return !content.includes('Ronan LE MEILLAT for SCTG Development')
}
const copyrightText = `// Copyright (c) 2024 Ronan LE MEILLAT for SCTG Development
//
// Turgeand-messaging is free software: you can redistribute it and/or modify
// it under the terms of the Affero General Public License version 3 as
// published by the Free Software Foundation.
//
// Turgeand-messaging is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Affero General Public License for more details.
//
// You should have received a copy of the Affero General Public License
// along with Turgeand-messaging. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>.`
const copyrightBash = `#!/bin/bash
# Copyright (c) 2024 Ronan LE MEILLAT for SCTG Development
#
# Turgeand-messaging is free software: you can redistribute it and/or modify
# it under the terms of the Affero General Public License version 3 as
# published by the Free Software Foundation.
#
# Turgeand-messaging is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Affero General Public License for more details.
#
# You should have received a copy of the Affero General Public License
# along with Turgeand-messaging. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>.`
gulp.task('licenses', async function () {
// this is to add Copyright in the production mode for the minified js
gulp
.src(['**/*.ts','**/*.mts'], { base: './' })
.pipe(gulpif(checkCopyright, gap.prependText(copyrightText)))
.pipe(gulp.dest('./', { overwrite: true }))
gulp
.src(['**/*.sh'], { base: './' })
.pipe(gulpif(checkCopyright, gap.prependText(copyrightBash)))
.pipe(gulp.dest('./', { overwrite: true }))
return
})