✌️
This commit is contained in:
		
							parent
							
								
									9a8af4a181
								
							
						
					
					
						commit
						706f495e79
					
				
					 2 changed files with 22 additions and 4 deletions
				
			
		
							
								
								
									
										20
									
								
								gulpfile.ts
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								gulpfile.ts
									
										
									
									
									
								
							|  | @ -3,7 +3,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| import * as fs from 'fs'; | import * as fs from 'fs'; | ||||||
| import * as path from 'path'; | import * as Path from 'path'; | ||||||
| import * as gulp from 'gulp'; | import * as gulp from 'gulp'; | ||||||
| import * as gutil from 'gulp-util'; | import * as gutil from 'gulp-util'; | ||||||
| import * as babel from 'gulp-babel'; | import * as babel from 'gulp-babel'; | ||||||
|  | @ -71,9 +71,20 @@ function getLicenseHtml(path: string): string { | ||||||
| 		.replace(/(^|\n)(.*?)($|\n)/g, '<p>$2</p>'); | 		.replace(/(^|\n)(.*?)($|\n)/g, '<p>$2</p>'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function getLicenseSectionHtml(path: string): string { | ||||||
|  | 	try { | ||||||
|  | 		const pkg = JSON.parse(fs.readFileSync(Path.parse(path).dir + '/package.json', 'utf-8')); | ||||||
|  | 		const licenseHtml = getLicenseHtml(path); | ||||||
|  | 		return `<details><summary>${pkg.name} <small>v${pkg.version}</small></summary>${licenseHtml}</details>`; | ||||||
|  | 	} catch (e) { | ||||||
|  | 		return null; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| gulp.task('build:about:docs', () => { | gulp.task('build:about:docs', () => { | ||||||
| 	const licenses = glob.sync('./node_modules/**/LICENSE*'); | 	const licenses = glob.sync('./node_modules/**/LICENSE*'); | ||||||
| 	const licenseHtml = [getLicenseHtml('./LICENSE')].concat(licenses.map(license => getLicenseHtml(license))).join('<hr>'); | 	const licenseHtml = getLicenseHtml('./LICENSE'); | ||||||
|  | 	const thirdpartyLicensesHtml = licenses.map(license => getLicenseSectionHtml(license)).join(''); | ||||||
| 	const pugs = glob.sync('./src/web/about/pages/**/*.pug'); | 	const pugs = glob.sync('./src/web/about/pages/**/*.pug'); | ||||||
| 	const streams = pugs.map(file => { | 	const streams = pugs.map(file => { | ||||||
| 		const page = file.replace('./src/web/about/pages/', '').replace('.pug', ''); | 		const page = file.replace('./src/web/about/pages/', '').replace('.pug', ''); | ||||||
|  | @ -81,10 +92,11 @@ gulp.task('build:about:docs', () => { | ||||||
| 			.pipe(pug({ | 			.pipe(pug({ | ||||||
| 				locals: Object.assign({ | 				locals: Object.assign({ | ||||||
| 					path: page, | 					path: page, | ||||||
| 					license: licenseHtml | 					license: licenseHtml, | ||||||
|  | 					thirdpartyLicenses: thirdpartyLicensesHtml | ||||||
| 				}, config) | 				}, config) | ||||||
| 			})) | 			})) | ||||||
| 			.pipe(gulp.dest('./built/web/about/pages/' + path.parse(page).dir)); | 			.pipe(gulp.dest('./built/web/about/pages/' + Path.parse(page).dir)); | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	return es.merge.apply(es, streams); | 	return es.merge.apply(es, streams); | ||||||
|  |  | ||||||
|  | @ -7,3 +7,9 @@ block content | ||||||
| 	h1 ライセンス | 	h1 ライセンス | ||||||
| 
 | 
 | ||||||
| 	div!= license | 	div!= license | ||||||
|  | 
 | ||||||
|  | 	hr | ||||||
|  | 
 | ||||||
|  | 	details | ||||||
|  | 		summary サードパーティ | ||||||
|  | 		div!= thirdpartyLicenses | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue