Skip to content

fix(gen:test): refactor gen to fix tests w/ pug #2722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export class Generator extends Base {

// Convert HTML into Pug
if(this.filters.pug) {
let pugFilter = filter(['**/*.html', '!client/app.template.html'], {restore: true});
const pugFilter = filter(['**/*.pug'], {restore: true});

function pugReplacer(contents) {
return contents
Expand All @@ -571,9 +571,8 @@ export class Generator extends Base {
rename(path => {
path.extname = '.pug';
}),
tap(function(file, t) {
var contents = file.contents.toString();
contents = pugReplacer(contents);
tap(file => {
const contents = pugReplacer(file.contents.toString());
file.contents = new Buffer(contents);
}),
pugFilter.restore
Expand Down
6 changes: 5 additions & 1 deletion src/generators/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function templateIsUsable(self, filteredFile) {
}

/**
*
*
*/
export function processDirectory(source, destination) {
var self = this;
Expand Down Expand Up @@ -171,6 +171,10 @@ export function processDirectory(source, destination) {
copy = true;
}

if(self.filters.pug && dest.indexOf('.html') !== -1 && dest.indexOf('app.template') === -1) {
dest = dest.replace('.html', '.pug');
}

if(templateIsUsable(self, filteredFile)) {
if(copy) {
self.fs.copy(src, dest);
Expand Down
2 changes: 1 addition & 1 deletion src/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe('angular-fullstack:app', function() {
var testOptions = {
buildtool: 'gulp',
transpiler: 'ts',
markup: 'pug',
markup: 'html',
stylesheet: 'less',
router: 'ngroute',
testing: 'jasmine',
Expand Down
2 changes: 1 addition & 1 deletion src/test/test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function runGen(prompts, opts={}) {
})
.withGenerators([
require.resolve('../generators/endpoint'),
// [helpers.createDummyGenerator(), 'ng-component:app']
[helpers.createDummyGenerator(), 'angular-fullstack-component:app']
])
// .withArguments(['upperCaseBug'])
.withOptions(options);
Expand Down
7 changes: 2 additions & 5 deletions templates/app/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"babel-preset-es2017": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-runtime": "^6.18.0",<% if(filters.pug) { %>
"pug": "2.0.0-beta6",<% } %><% if(filters.html) { %>
"pug": "^2.0.0",<% } %><% if(filters.html) { %>
"ejs": "^2.5.3",<% } %><% if(filters.mongoose) { %>
"mongoose": "^4.1.2",
"bluebird": "^3.3.3",
Expand Down Expand Up @@ -106,7 +106,6 @@
<%# END CLIENT %>

"autoprefixer": "^7.1.3",
"babel-core": "^6.6.5",
"babel-eslint": "^7.2.3",
"babel-register": "^6.16.0",
"bs-fullscreen-message": "^1.0.0",
Expand All @@ -115,10 +114,8 @@
"babel-plugin-syntax-flow": "^6.8.0",
"babel-plugin-transform-flow-comments": "^6.8.0",<% } %>
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-plugin-istanbul": "^4.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.6.0",
"cross-env": "^5.1.1",
"eslint": "^2.12.0",
"del": "^3.0.0",
Expand Down Expand Up @@ -157,7 +154,7 @@
"html-webpack-plugin": "^2.24.1",
"html-webpack-harddisk-plugin": "~0.1.0",
<%_ if(filters.pug) { _%>
"pug-html-loader": "^1.0.8",<% } %>
"pug-html-loader": "^1.1.5",<% } %>
"typescript": "~2.6.1",
"awesome-typescript-loader": "^3.3.0",
"babel-loader": "^7.1.2",
Expand Down