Skip to content
Permalink
Browse files

fix(npmignore): add npm prepublish script to remove bower_components …

…directory
  • Loading branch information
jyounce committed Aug 26, 2015
1 parent f0907c1 commit 03da37444dcb3236a719a0c8ba8123606ceabc8b
Showing with 53 additions and 1 deletion.
  1. +1 −1 .npmignore
  2. +3 −0 package.json
  3. +21 −0 scripts/helpers/log-msg.js
  4. +28 −0 scripts/prepublish.js
@@ -1,6 +1,6 @@
# folders
# =======
bower_components/
bower_components/ # also see scripts/prepublish.js
dist/

# dot files
@@ -20,6 +20,9 @@
"node": ">=0.10.0"
},
"main": "gulpfile.js",
"scripts": {
"prepublish": "node scripts/prepublish"
},
"devDependencies": {
"conventional-changelog": "~0.4.2",
"prepend-file": "~1.3.0"
@@ -0,0 +1,21 @@
require('colors')

var getSeparator = function(msg) {
var i = 0
var sep = ''
var len = msg.length
for (; i < len; i++) {
sep += '-'
}
return sep
}

var logMsg = function(msg) {
var sep = getSeparator(msg)
console.log(sep)
console.log(msg.toUpperCase().yellow)
console.log(sep)
return
}

module.exports = logMsg
@@ -0,0 +1,28 @@
/**
* Ensure bower_components dir gets removed before publishing to npm.
* .npmignore is not enough because some bower packages
* contain: package.json and/or README.md
* and these files never get ignored.
**********************************************************************/
var bowerPath, cwd, fse, logMsg, path, q;

q = require('q')
path = require('path')
fse = require('fs-extra')
logMsg = require('./helpers/log-msg')
cwd = process.cwd()
bowerPath = path.join(cwd, 'src', 'client', 'bower_components'); // ; required

/**
* Init
*/
(function() {
var defer = q.defer()
logMsg('npm prepublish')
fse.remove(bowerPath, function(e) {
if (e) return console.log(e)
console.log('removed bower_components directory')
return defer.resolve()
})
return defer.promise
})()

0 comments on commit 03da374

Please sign in to comment.
You can’t perform that action at this time.