Skip to content

Commit 14fd483

Browse files
committed
attempt to avert disaster issue 246
1 parent 93db5f5 commit 14fd483

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

scripts/mockPublish

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
mkdir -p ./tmp
6+
npm pack
7+
mv *.tgz ./tmp
8+
tar xvzf tmp/*.tgz -C ./tmp
9+
10+
exit 0

scripts/publish

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
echo 'Testing Package for publishing...'
6+
./node_modules/.bin/tape ./test/publish.js
7+
8+
echo 'Attempting npm publish...'
9+
npm publish
10+
11+
echo 'Success'
12+
13+
exit 0

test/publish.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
var test = require('tape');
4+
var exec = require('child_process').exec;
5+
6+
function cleanUp(cb) {
7+
return exec('rm -rf ./tmp', cb);
8+
}
9+
10+
function makeTestPackage(cb) {
11+
return exec('./scripts/mockPublish', cb);
12+
}
13+
14+
// with regards to averting npm publishing disasters https://github.com/floridoo/gulp-sourcemaps/issues/246
15+
test('can load a published version', function(t) {
16+
// return t.fail("mock fail");
17+
cleanUp(function() {
18+
makeTestPackage(function() {
19+
try {
20+
// attempt to load a packed / unpacked potential deployed version
21+
require('../tmp/package/index');
22+
}
23+
catch (error){
24+
t.fail(error);
25+
}
26+
finally{
27+
cleanUp(function() {
28+
t.end();
29+
});
30+
}
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)