diff --git a/Gruntfile.js b/Gruntfile.js index 5f7d56c9..43772588 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -28,6 +28,13 @@ module.exports = function(grunt) { fix: true }, src: ['src/**/*.js', 'test/tests/**/*.js'] + }, + sourceNofix: { + options: { + configFile: './.eslintrc', + fix: false + }, + src: ['src/**/*.js', 'test/tests/**/*.js'] } }, webpack: { @@ -59,7 +66,10 @@ module.exports = function(grunt) { }, githooks: { all: { - 'pre-commit':'lint' //runs linting test before every git commit + options:{ + template:"templates/pre-commit-hook.js" + }, + 'pre-commit':'lint-nofix' //runs linting test before every git commit } } }); @@ -73,6 +83,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-githooks'); grunt.registerTask('lint', ['eslint:source']); + grunt.registerTask('lint-nofix', ['eslint:sourceNofix']); grunt.registerTask('default', ['webpack:prod', 'decomment']); grunt.registerTask('dev', ['eslint','connect','webpack:dev', 'decomment']); grunt.registerTask('serve', 'connect:server:keepalive'); diff --git a/src/app.js b/src/app.js index 1f744ec8..dc2c87f3 100644 --- a/src/app.js +++ b/src/app.js @@ -7,7 +7,6 @@ p5.prototype.userStartAudio = userStartAudio; import './master'; - import { sampleRate, freqToMidi, @@ -21,10 +20,7 @@ import { interleave, writeUTFBytes, safeBufferSize, - - saveSound - - + saveSound, } from './helpers'; p5.prototype.sampleRate = sampleRate; p5.prototype.freqToMidi = freqToMidi; @@ -44,7 +40,6 @@ p5.prototype.saveSound = saveSound; // Oscillators etc when sketch ends p5.prototype.registerMethod('remove', p5.prototype.disposeSound); - import './errorHandler'; import './audioWorklet'; @@ -57,7 +52,6 @@ p5.prototype.loadSound = loadSound; // register preload handling of loadSound p5.prototype.registerPreloadMethod('loadSound', p5.prototype); - import Amplitude from './amplitude'; p5.Amplitude = Amplitude; @@ -75,15 +69,12 @@ p5.SqrOsc = SqrOsc; import './envelope'; - import Noise from './noise'; p5.Noise = Noise; import Pulse from './pulse'; p5.Pulse = Pulse; - - import AudioIn from './audioin'; p5.AudioIn = AudioIn; @@ -108,42 +99,29 @@ p5.Panner3D = Panner3D; import Delay from './delay'; p5.Delay = Delay; - - - import { Reverb, Convolver, createConvolver } from './reverb'; p5.Reverb = Reverb; p5.Convolver = Convolver; p5.prototype.createConvolver = createConvolver; p5.prototype.registerPreloadMethod('createConvolver', p5.prototype); - - import Metro from './metro'; p5.Metro = Metro; - import { Phrase, Part, Score } from './looper'; p5.Phrase = Phrase; p5.Part = Part; p5.Score = Score; - import SoundLoop from './soundLoop'; p5.SoundLoop = SoundLoop; - import Compressor from './compressor'; p5.Compressor = Compressor; - - import peakDetect from './peakDetect'; p5.peakDetect = peakDetect; - - - import SoundRecorder from './soundRecorder'; p5.SoundRecorder = SoundRecorder; diff --git a/src/helpers.js b/src/helpers.js index 58af9b22..cc252f95 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -331,7 +331,6 @@ function safeBufferSize(idealBufferSize) { return bufferSize; } - /** * Save a p5.SoundFile as a .wav file. The browser will prompt the user * to download the file to their device. @@ -349,7 +348,6 @@ function saveSound(soundFile, fileName) { p5.prototype.writeFile([dataView], fileName, 'wav'); } - export { sampleRate, freqToMidi, @@ -363,5 +361,5 @@ export { interleave, writeUTFBytes, safeBufferSize, - saveSound + saveSound, }; diff --git a/src/panner.js b/src/panner.js index 69e1f944..595116fe 100644 --- a/src/panner.js +++ b/src/panner.js @@ -108,6 +108,4 @@ if (typeof ac.createStereoPanner !== 'undefined') { panner = Panner; } - export default panner; - diff --git a/templates/pre-commit-hook.js b/templates/pre-commit-hook.js new file mode 100644 index 00000000..a7a38618 --- /dev/null +++ b/templates/pre-commit-hook.js @@ -0,0 +1,32 @@ + // hooks/pre-commit.js + + var exec = require('child_process').exec; + // Executes shell commands synchronously + var sh = require('child_process').execSync; + + exec('git diff --cached --quiet', function (err, stdout, stderr) { + + // only run if there are staged changes + // i.e. what you would be committing if you ran "git commit" without "-a" option. + if (err) { + + // stash unstaged changes - only test what's being committed + sh('git stash --keep-index --quiet'); + + exec('grunt {{task}}', function (err, stdout, stderr) { + + console.log(stdout); + + // restore stashed changes + sh('git stash pop --quiet'); + + var exitCode = 0; + if (err) { + console.log(stderr); + exitCode = -1; + } + process.exit(exitCode); + }); + } + + }); \ No newline at end of file