Skip to content

Commit

Permalink
feat(view sub-generator): add notification when leaving 'src/sass/_vi…
Browse files Browse the repository at this point in the history
…ews.sass' untouched.
  • Loading branch information
cueedee committed May 7, 2015
1 parent 40cc8e9 commit 9d1d0f1
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions generators/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,36 @@ var ViewGenerator = generators.Base.extend(

updateViewsSass: function () {

/* jshint laxbreak: true */

if ( !( this.sassFile )) { return; }

//
// Add an `@import "views/_<fileBase>" statement to the '_views.sass' file.
//

var views = this.readFileAsString( 'src/sass/_views.sass' )
, insert = '@import "views/_' + this.fileBase + '"'
var viewsPath = 'src/sass/_views.sass'
, views = this.readFileAsString( viewsPath )
, statement = '@import "views/_' + this.fileBase + '"'
;

// Check if there isn't already in import for this file
// just in case....
// Do nothing if an `@import` for this sass file seems to exist already.
//
if ( views.indexOf( insert ) === -1 )
if ( views.indexOf( statement ) !== -1 )
{
// Avoid the conflict warning and use force for the write
//
this.conflicter.force = true;
this.log(
'It appears that "' + viewsPath + '" already contains an `@import` for "' + this.fileBase + '.sass".\n'
+ 'Leaving it untouched.'
);

this.write( 'src/sass/_views.sass', views + '\n' + insert );
return;
}

// Avoid the conflict warning and use force for the write
//
this.conflicter.force = true;

this.write( viewsPath, views + '\n' + statement );
}
}
}
Expand Down

0 comments on commit 9d1d0f1

Please sign in to comment.