Skip to content
Browse files

Publish project to npm

  • Loading branch information...
1 parent dc6c483 commit db97b7341cefa5a91be9a7226a86a0f7d8058198 @richardhodgson richardhodgson committed Nov 14, 2011
Showing with 19 additions and 0 deletions.
  1. +2 −0 bin/usenode-release
  2. +4 −0 tests/mock/npm
  3. +13 −0 tests/test-release
View
2 bin/usenode-release
@@ -40,3 +40,5 @@ git commit -m "Version for release $NEW_VERSION" package.json
git tag v$NEW_VERSION
git push origin master
git push --tags)
+
+npm publish $PROJECT
View
4 tests/mock/npm
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo "Stub: npm called with command '$*'"
+echo "$*" > `dirname $0`/npm.log
View
13 tests/test-release
@@ -3,6 +3,9 @@
ROOT=`dirname $0`
MOCKPROJECT=$ROOT/../../usenode-release-mockproject
+# Set up mocked dependencies
+export PATH="$ROOT/mock:$PATH"
+
function assert {
ACTUAL=$1
EXPECTED=$2
@@ -19,13 +22,15 @@ function assert {
# Make sure we can assert things
assert true true "Can make assertions"
+##
# Test input validation
MISSING_ARGUMENTS=`$ROOT/../bin/usenode-release`
assert "$MISSING_ARGUMENTS" "Usage: usenode-publish path/to/project [new_version]" "Script outputs usage message if no arguments are passed"
CANNOT_FIND_PACKAGE_JSON=`$ROOT/../bin/usenode-release $MOCKPROJECT-does-not-exist`
assert "$CANNOT_FIND_PACKAGE_JSON" "Could not find package.json at $MOCKPROJECT-does-not-exist/package.json" "Script throws an error if cannot find package.json at project location"
+##
# Test package.json is updated
$ROOT/create-mock-project $MOCKPROJECT > /dev/null
$ROOT/../bin/usenode-release $MOCKPROJECT 2.3.4
@@ -38,3 +43,11 @@ assert "$PACKAGE_COMMIT_MESSAGE_FROM_LOG" " Version for release 2.3.4" "Chang
REMOTE_LOG=`cd $MOCKPROJECT-head; git log | egrep 'Version'`
assert "$REMOTE_LOG" " Version for release 2.3.4" "Changes are pushed to remote"
+
+##
+# Test project is published to npm
+MOCK_NPM_LOG=`cat $ROOT/mock/npm.log`
+assert "$MOCK_NPM_LOG" "publish $MOCKPROJECT" "Project is published to npm"
+
+#tear down
+rm $ROOT/mock/npm.log

0 comments on commit db97b73

Please sign in to comment.
Something went wrong with that request. Please try again.