-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34dc9f8
commit 8e7187d
Showing
7 changed files
with
241 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
version: 2.1 | ||
|
||
refs: | ||
- &only_master | ||
filters: | ||
branches: | ||
only: master | ||
|
||
- ¬_master | ||
filters: | ||
branches: | ||
ignore: master | ||
|
||
workflows: | ||
test: | ||
jobs: | ||
- unit-tests: | ||
<<: *not_master | ||
name: node-6 | ||
version: '6' | ||
- unit-tests: | ||
<<: *not_master | ||
name: node-8 | ||
version: '8' | ||
- unit-tests: | ||
<<: *not_master | ||
name: node-10 | ||
version: '10' | ||
- unit-tests: | ||
<<: *not_master | ||
name: node-12 | ||
version: '12' | ||
- unit-tests: | ||
<<: *not_master | ||
name: node-14 | ||
version: '14' | ||
|
||
release: | ||
jobs: | ||
- unit-tests: | ||
<<: *only_master | ||
name: node-6 | ||
version: '6' | ||
- unit-tests: | ||
<<: *only_master | ||
name: node-8 | ||
version: '8' | ||
- unit-tests: | ||
<<: *only_master | ||
name: node-10 | ||
version: '10' | ||
- unit-tests: | ||
<<: *only_master | ||
name: node-12 | ||
version: '12' | ||
- unit-tests: | ||
<<: *only_master | ||
name: node-14 | ||
version: '14' | ||
|
||
- publish-dry-run: | ||
<<: *only_master | ||
context: common-env | ||
|
||
- publish-approval: | ||
type: approval | ||
context: common-env | ||
requires: | ||
- publish-dry-run | ||
|
||
- publish: | ||
<<: *only_master | ||
context: common-env | ||
requires: | ||
- node-6 | ||
- node-8 | ||
- node-10 | ||
- node-12 | ||
- node-14 | ||
- publish-approval | ||
|
||
jobs: | ||
unit-tests: | ||
parameters: | ||
version: | ||
type: string | ||
docker: | ||
- image: circleci/node:<< parameters.version >> | ||
steps: | ||
- setup | ||
- test | ||
|
||
publish-dry-run: | ||
docker: | ||
- image: circleci/node:12 | ||
steps: | ||
- setup | ||
- publish-dry-run | ||
|
||
publish: | ||
docker: | ||
- image: circleci/node:12 | ||
steps: | ||
- setup | ||
- publish | ||
|
||
commands: | ||
setup: | ||
description: 'Checkout and install dependencies' | ||
steps: | ||
- checkout | ||
- run: | ||
name: Versions | ||
command: node -v && npm -v | ||
- run: | ||
name: Install Dependencies | ||
command: npm i | ||
|
||
test: | ||
steps: | ||
- run: | ||
name: Test | ||
command: npm test | ||
- run: | ||
name: Pack | ||
command: npm pack | ||
- run: | ||
name: Setup Import Test | ||
command: echo $PWD && cd .. && mkdir test-import && cp -a project/test-import/ test-import/test-import/ && cd test-import && npm init -y && npm i ../project/is-promise-2.2.2.tgz | ||
- run: | ||
name: Test Import | ||
command: cd ../test-import && node test-import/test.js | ||
|
||
publish-dry-run: | ||
steps: | ||
- run: | ||
name: NPM Auth | ||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||
- run: | ||
name: Release (Dry Run) | ||
command: npx rollingversions publish --dry-run | ||
|
||
publish: | ||
steps: | ||
- run: | ||
name: NPM Auth | ||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||
- run: | ||
name: Release | ||
command: npx rollingversions publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var assert = require('assert'); | ||
var isPromise = require('is-promise'); | ||
|
||
|
||
assert(isPromise(null) === false); | ||
assert(isPromise(undefined) === false); | ||
assert(isPromise(0) === false); | ||
assert(isPromise(-42) === false); | ||
assert(isPromise(42) === false); | ||
assert(isPromise('') === false); | ||
assert(isPromise('then') === false); | ||
assert(isPromise(false) === false); | ||
assert(isPromise(true) === false); | ||
assert(isPromise({}) === false); | ||
assert(isPromise({then: true}) === false); | ||
assert(isPromise([]) === false); | ||
assert(isPromise([true]) === false); | ||
assert(isPromise(() => {}) === false); | ||
|
||
// This looks similar enough to a promise | ||
// that promises/A+ says we should treat | ||
// it as a promise. | ||
var promise = {then: function () {}}; | ||
|
||
assert(isPromise(promise) === true); | ||
const fn = () => {}; | ||
fn.then = () => {}; | ||
assert(isPromise(fn) === true); | ||
|
||
console.log('CommonJS tests passed') | ||
|
||
if(parseInt(process.version.split('.')[0].substr(1), 10) >= 14) { | ||
const result = require('child_process').spawnSync('node', ['test.mjs'], {cwd: __dirname, stdio: 'inherit'}); | ||
process.exit(result.status); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import assert from 'assert'; | ||
import isPromise from 'is-promise'; | ||
|
||
|
||
assert(isPromise(null) === false); | ||
assert(isPromise(undefined) === false); | ||
assert(isPromise(0) === false); | ||
assert(isPromise(-42) === false); | ||
assert(isPromise(42) === false); | ||
assert(isPromise('') === false); | ||
assert(isPromise('then') === false); | ||
assert(isPromise(false) === false); | ||
assert(isPromise(true) === false); | ||
assert(isPromise({}) === false); | ||
assert(isPromise({then: true}) === false); | ||
assert(isPromise([]) === false); | ||
assert(isPromise([true]) === false); | ||
assert(isPromise(() => {}) === false); | ||
|
||
// This looks similar enough to a promise | ||
// that promises/A+ says we should treat | ||
// it as a promise. | ||
var promise = {then: function () {}}; | ||
|
||
assert(isPromise(promise) === true); | ||
const fn = () => {}; | ||
fn.then = () => {}; | ||
assert(isPromise(fn) === true); | ||
|
||
console.log('ES Modules tests passed') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,30 @@ | ||
var assert = require('assert'); | ||
var isPromise = require('./'); | ||
var assert = require('better-assert'); | ||
|
||
|
||
assert(isPromise(null) === false); | ||
assert(isPromise(undefined) === false); | ||
assert(isPromise(0) === false); | ||
assert(isPromise(-42) === false); | ||
assert(isPromise(42) === false); | ||
assert(isPromise('') === false); | ||
assert(isPromise('then') === false); | ||
assert(isPromise(false) === false); | ||
assert(isPromise(true) === false); | ||
assert(isPromise({}) === false); | ||
assert(isPromise({then: true}) === false); | ||
assert(isPromise([]) === false); | ||
assert(isPromise([true]) === false); | ||
assert(isPromise(() => {}) === false); | ||
|
||
// This looks similar enough to a promise | ||
// that promises/A+ says we should treat | ||
// it as a promise. | ||
var promise = {then: function () {}}; | ||
|
||
describe('calling isPromise', function () { | ||
describe('with a promise', function () { | ||
it('returns true', function () { | ||
assert(isPromise(promise)); | ||
}); | ||
}); | ||
describe('with null', function () { | ||
it('returns false', function () { | ||
assert(isPromise(null) === false); | ||
}); | ||
}); | ||
describe('with undefined', function () { | ||
it('returns false', function () { | ||
assert(isPromise(undefined) === false); | ||
}); | ||
}); | ||
describe('with a number', function () { | ||
it('returns false', function () { | ||
assert(!isPromise(0)); | ||
assert(!isPromise(-42)); | ||
assert(!isPromise(42)); | ||
}); | ||
}); | ||
describe('with a string', function () { | ||
it('returns false', function () { | ||
assert(!isPromise('')); | ||
assert(!isPromise('then')); | ||
}); | ||
}); | ||
describe('with a bool', function () { | ||
it('returns false', function () { | ||
assert(!isPromise(false)); | ||
assert(!isPromise(true)); | ||
}); | ||
}); | ||
describe('with an object', function () { | ||
it('returns false', function () { | ||
assert(!isPromise({})); | ||
assert(!isPromise({then: true})); | ||
}); | ||
}); | ||
describe('with an array', function () { | ||
it('returns false', function () { | ||
assert(!isPromise([])); | ||
assert(!isPromise([true])); | ||
}); | ||
}); | ||
describe('with a func', function () { | ||
it('returns false', function () { | ||
assert(!isPromise(() => {})); | ||
}); | ||
}); | ||
describe('with a func with .then method', function () { | ||
it('returns true', function () { | ||
const fn = () => {}; | ||
fn.then = () => {}; | ||
assert(isPromise(fn)); | ||
}); | ||
}); | ||
}); | ||
assert(isPromise(promise) === true); | ||
const fn = () => {}; | ||
fn.then = () => {}; | ||
assert(isPromise(fn) === true); | ||
|
||
console.log('tests passed') |