[
  {
    "path": ".github/ISSUE_TEMPLATE/project-not-maintained.md",
    "content": "---\nname: Project not maintained\nabout: This project is no longer maintained\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\nThe best option is to switch to a library that supports promises - either https://github.com/jprichardson/tape-promise or https://www.node-tap.org/ - or perhaps its time to revisit substack/tape/issues/262 and add promise support to tape.\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n"
  },
  {
    "path": ".npmignore",
    "content": "test\n.gitignore\n"
  },
  {
    "path": "README.md",
    "content": "#### This project is no longer maintained.\n\nThe best option is to switch to a library that supports promises - either https://github.com/jprichardson/tape-promise or https://github.com/tapjs/node-tap - or perhaps its time to revisit https://github.com/substack/tape/issues/262 and add promise support to tape.\n\n--------------\n\n# blue-tape\n\nTape with promise support.\n\n### Usage\n\nSame as [tape](https://github.com/substack/tape), except if you return a promise from a test,\nit will be checked for errors. If there are no errors, the test will end. Otherwise the test\nwill fail. This means there is no need to use `t.plan()` or `t.end()`.\n\nAlso provides `t.shouldFail(promise P, optional class|regex expected, optional message)` (as\nwell as the alias `shouldReject`) which returns a new promise that resolves successfully if `P`\nrejects. If you provide the optional class, or regex then it additionally ensures that `err` is\nan instance of that class or that the message matches the regular expression. The behaviour is\nidentical to tape's `throws` assertion.\n\n### Examples\n\nAssuming `delay()` returns a promise:\n\n```js\nconst test = require('blue-tape');\n\ntest(\"simple delay\", function(t) {\n    return delay(1);\n});\n\ntest(\"should fail\", function(t) {\n    return delay(1).then(function() {\n        throw new Error(\"Failed!\");\n    });\n});\n```\n\nAssuming `failDelay()` returns a promise that rejects with a DerpError:\n\n```js\ntest(\"promise fails but test succeeds\", function(t) {\n    return t.shouldFail(failDelay(), DerpError);\n});\n```\n\n### License\n\nMIT\n"
  },
  {
    "path": "bin/blue-tape.js",
    "content": "#!/usr/bin/env node\n\nrequire('tape/bin/tape')\n"
  },
  {
    "path": "blue-tape.js",
    "content": "var Test = require('tape/lib/test')\n\nfunction checkPromise (p) {\n  return p && p.then && typeof p.then === 'function'\n}\n\nTest.prototype.run = function () {\n  if (this._skip) {\n    return this.end()\n  }\n  this.emit('prerun')\n  try {\n    var p = this._cb && this._cb(this)\n    var isPromise = checkPromise(p)\n    var self = this\n    if (isPromise) {\n      p.then(function () {\n        self.end()\n      }, function (err) {\n        err ? self.error(err) : self.fail(err)\n        self.end()\n      })\n    }\n  } catch (err) {\n    if (err) {\n      this.error(err)\n    } else {\n      this.fail(err)\n    }\n    this.end()\n    return\n  }\n  this.emit('run')\n}\n\nfunction noop() {}\n\nTest.prototype.shouldFail =\nTest.prototype.shouldReject =\nfunction (promise, expected, message, extra) {\n  var self = this\n  return promise.then(function () {\n    self.throws(noop, expected, message, extra)\n  }, function (err) {\n    function f() {throw err}\n    self.throws(f, expected, message, extra)\n  })\n}\n\n\nmodule.exports = require('tape')\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"blue-tape\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Tape test runner with promise support\",\n  \"main\": \"blue-tape.js\",\n  \"bin\": {\n    \"blue-tape\": \"./bin/blue-tape.js\"\n  },\n  \"scripts\": {\n    \"test\": \"standard && node test/index.js\"\n  },\n  \"keywords\": [\n    \"tape\",\n    \"bluebird\",\n    \"promises\"\n  ],\n  \"author\": \"spion\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"tape\": \">=2.0.0 <5.0.0\"\n  },\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/spion/blue-tape.git\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/spion/blue-tape/issues\"\n  },\n  \"devDependencies\": {\n    \"bl\": \"^4.0.3\",\n    \"bluebird\": \"^2.1.2\",\n    \"standard\": \"*\"\n  }\n}\n"
  },
  {
    "path": "test/index.js",
    "content": "var tape = require('../blue-tape')\nvar bl = require('bl')\nvar P = require('bluebird')\nP.longStackTraces()\n\nfunction test (name, test, checkErrors) {\n  tape.test(name, function (t) {\n    var htest = tape.createHarness()\n    htest.createStream().pipe(bl(function (_, data) {\n      checkErrors && checkErrors(data.toString().split('\\n'), t)\n    }))\n    htest(function (t) {\n      return test(t, htest)\n    })\n  })\n}\n\nfunction verifyAsserts (counts) {\n  return function (lines, t) {\n    t.equal(count(lines, /^ok/), counts.ok, 'should have ' + counts.ok + ' ok asserts')\n    t.equal(count(lines, /^not ok/), counts.fail, 'should have ' + counts.fail + ' failed asserts')\n    t.end()\n  }\n}\n\nfunction count (lines, regex) {\n  var c = 0\n  for (var k = 0; k < lines.length; ++k) {\n    if (regex.test(lines[k])) {\n      ++c\n    }\n  }\n  return c\n}\n\ntest('non-promise test', function (t) {\n  t.ok(true)\n  t.end()\n},\n  verifyAsserts({ok: 1, fail: 0}))\n\ntest('simple delay', function (t) {\n  return P.delay(1)\n},\n  verifyAsserts({ok: 0, fail: 0}))\n\ntest('should not affect plan', function (t) {\n  t.plan(2)\n  t.ok(true)\n  t.ok(true)\n  return P.delay(1)\n},\n  verifyAsserts({ok: 2, fail: 0}))\n\ntest('nested tests with promises', function (t) {\n  t.test('delay1', function (t) {\n    return P.delay(1)\n  })\n  t.test('delay2', function () {\n    return P.delay(1)\n  })\n},\n  verifyAsserts({ok: 0, fail: 0}))\n\ntest('should error', function (t) {\n  return P.delay(1).then(function () {\n    throw new Error('Failed!')\n  })\n},\n  verifyAsserts({ok: 0, fail: 1}))\n\ntest('should fail', function (t) {\n  return P.delay(1).then(function () {\n    return P.reject()\n  })\n},\n  verifyAsserts({ok: 0, fail: 1}))\n\ntest('run test with only', function (t, htest) {\n  var count = 0\n  htest('first', function (t) {\n    t.equal(++count, 1)\n    t.end()\n  })\n  htest.only('second', function (t) {\n    t.equal(++count, 1)\n    t.end()\n  })\n  t.end()\n},\n  verifyAsserts({ok: 1, fail: 0}))\n\ntest('test that expects promise to fail', function (t) {\n  return t.shouldFail(P.delay(1).then(function () {\n    return P.reject(new Error(\"Test\"))\n  }))\n},\n  verifyAsserts({ok: 1, fail: 0}))\n\ntest('test that expects promise to fail, but it succeeds', function (t) {\n  return t.shouldFail(P.delay(1).then(function () {\n    return P.resolve()\n  }))\n},\n  verifyAsserts({ok: 0, fail: 1}))\n\ntest('test that expects specific exception', function (t) {\n  return t.shouldFail(P.delay(1).then(function () {\n    var f = 5\n    f.toFixed(100) // RangeError\n  }), RangeError)\n},\n  verifyAsserts({ok: 1, fail: 0}))\n\ntest('test that expects wrong exception', function (t) {\n  return t.shouldFail(P.delay(1).then(function () {\n    var f = 5\n    f.toFixed(100) // RangeError\n  }), SyntaxError)\n},\n  verifyAsserts({ok: 0, fail: 1}))\n"
  }
]