Skip to content

Commit

Permalink
Merge branch '1.X'
Browse files Browse the repository at this point in the history
  • Loading branch information
nmccready committed Oct 14, 2016
2 parents 48759d9 + 8abf069 commit 8b50f13
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
10 changes: 10 additions & 0 deletions scripts/mockPublish
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e
set -o pipefail

mkdir -p ./tmp
npm pack
mv *.tgz ./tmp
tar xvzf tmp/*.tgz -C ./tmp

exit 0
13 changes: 13 additions & 0 deletions scripts/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
set -o pipefail

echo 'Testing Package for publishing...'
./node_modules/.bin/tape ./test/publish.js

echo 'Attempting npm publish...'
npm publish

echo 'Success'

exit 0
18 changes: 15 additions & 3 deletions test/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ function makeFileCSS() {
}

test('init: should pass through when file is null', function(t) {
// Begin inner conflict with self here..
// nmccready:
//
//
// bliss: Turning debug on here clutters the test output;
// but, having debug off in portions results in not having 100% test coverage.
//
// touche: If we demand 100% coverage, then we need clutter logging :_(
//
// partial-bliss: The alternative is to have ignore cover statements on some of the logging.
// touche: However, those logging statements could potentially fail
debug.save('gulp-sourcemaps:init');
debug.enable(debug.load());
// end inner conflict
var file = new File();
var pipeline = sourcemaps.init();
pipeline.on('data', function(data) {
Expand Down Expand Up @@ -373,8 +387,6 @@ test('init: handle null contents', function(t) {

//should always be last as disabling a debug namespace does not work
test('init: should output an error message if debug option is set and sourceContent is missing', function(t) {
debug.save('gulp-sourcemaps:init');
debug.enable(debug.load());

var file = makeFile();
file.contents = new Buffer(sourceContent + '\n//# sourceMappingURL=helloworld4.js.map');
Expand All @@ -388,7 +400,7 @@ test('init: should output an error message if debug option is set and sourceCont

pipeline.on('data', function() {
unhook();
debug.save(null);
// debug.save(null);
t.ok(history.length == 4, 'history len');
t.ok(history[2].match(/No source content for \"missingfile\". Loading from file./), 'should log missing source content');
t.ok(history[3].match(/source file not found: /), 'should warn about missing file');
Expand Down
33 changes: 33 additions & 0 deletions test/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

var test = require('tape');
var exec = require('child_process').exec;

function cleanUp(cb) {
return exec('rm -rf ./tmp', cb);
}

function makeTestPackage(cb) {
return exec('./scripts/mockPublish', cb);
}

// with regards to averting npm publishing disasters https://github.com/floridoo/gulp-sourcemaps/issues/246
test('publish: can load a published version', function(t) {
// return t.fail("mock fail");
cleanUp(function() {
makeTestPackage(function() {
try {
// attempt to load a packed / unpacked potential deployed version
require('../tmp/package/index');
}
catch (error){
t.fail(error);
}
finally{
cleanUp(function() {
t.end();
});
}
});
});
});

0 comments on commit 8b50f13

Please sign in to comment.