mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Workaround for Yeoman generators not producing .gitignore files due to Yeoman issue #1862
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -29,3 +29,10 @@ project.lock.json
|
||||
.vs/
|
||||
npm-debug.log
|
||||
/.build/
|
||||
|
||||
# The templates can't contain their own .gitignore files, because Yeoman has strange default handling for
|
||||
# files with that name (https://github.com/npm/npm/issues/1862). So, each template instead has a template_gitignore
|
||||
# file which gets renamed after the files are copied. And so any files that need to be excluded in the source
|
||||
# repo have to be excluded here.
|
||||
/templates/*/node_modules/
|
||||
/templates/*/wwwroot/dist/
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as _ from 'lodash';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as rimraf from 'rimraf';
|
||||
|
||||
const textFileExtensions = ['.gitignore', '.config', '.cs', '.cshtml', 'Dockerfile', '.html', '.js', '.json', '.jsx', '.md', '.ts', '.tsx', '.xproj'];
|
||||
const textFileExtensions = ['.gitignore', 'template_gitignore', '.config', '.cs', '.cshtml', 'Dockerfile', '.html', '.js', '.json', '.jsx', '.md', '.ts', '.tsx', '.xproj'];
|
||||
|
||||
const templates = {
|
||||
'angular-2': '../../templates/Angular2Spa/',
|
||||
@@ -38,7 +38,10 @@ function writeFileEnsuringDirExists(root: string, filename: string, contents: st
|
||||
}
|
||||
|
||||
function listFilesExcludingGitignored(root: string): string[] {
|
||||
let gitIgnorePath = path.join(root, '.gitignore');
|
||||
// Note that the gitignore files, prior to be written by the generator, are called 'template_gitignore'
|
||||
// instead of '.gitignore'. This is a workaround for Yeoman doing strange stuff with .gitignore files
|
||||
// (it renames them to .npmignore, which is not helpful).
|
||||
let gitIgnorePath = path.join(root, 'template_gitignore');
|
||||
let gitignoreEvaluator = fs.existsSync(gitIgnorePath)
|
||||
? gitignore.compile(fs.readFileSync(gitIgnorePath, 'utf8'))
|
||||
: { accepts: () => true };
|
||||
|
||||
@@ -47,6 +47,11 @@ class MyGenerator extends yeoman.Base {
|
||||
// Token replacement in filenames
|
||||
let outputFn = fn.replace(/tokenreplace\-([^\.\/]*)/g, (substr, token) => this._answers[token]);
|
||||
|
||||
// Rename template_gitignore to .gitignore in output
|
||||
if (path.basename(fn) === 'template_gitignore') {
|
||||
outputFn = path.join(path.dirname(fn), '.gitignore');
|
||||
}
|
||||
|
||||
this.fs.copyTpl(
|
||||
path.join(templateRoot, fn),
|
||||
this.destinationPath(outputFn),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "generator-aspnetcore-spa",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"description": "Single-Page App templates for ASP.NET Core",
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Reference in New Issue
Block a user