diff --git a/.azure-pipelines-steps.yml b/.azure-pipelines-steps.yml new file mode 100644 index 000000000..58f9306e5 --- /dev/null +++ b/.azure-pipelines-steps.yml @@ -0,0 +1,31 @@ +# +# Steps for building and testing commander.js. See jobs defined in .azure-pipelines.yml. +# + +steps: + # Clones the repo. This is an explicit step to preserve symlinks for Windows. + - checkout: self + + - task: NodeTool@0 + inputs: + versionSpec: $(NODE_VERSION) + checkLatest: 'true' + displayName: 'Install Node.js' + + # Run npm ci by default unless NPM_INSTALL is set + - script: npm ci + displayName: 'Install dependencies' + condition: not(variables.NPM_INSTALL) + + # Otherwise, run npm install if NPM_INSTALL is set (typically for Node versions < 10.x) + - script: npm install + displayName: 'Install dependencies (npm install)' + condition: variables.NPM_INSTALL + + - script: npm run lint + displayName: 'Run lint' + condition: variables.LINT + + - script: npm run test + displayName: 'Run tests' + condition: not(variables.SKIP_TESTS) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml new file mode 100644 index 000000000..c41e7f9da --- /dev/null +++ b/.azure-pipelines.yml @@ -0,0 +1,49 @@ +# +# Azure Pipelines configuration for building and testing commander.js on Linux, Windows, and macOS. +# + +trigger: +- master + +jobs: +- job: Linux + pool: + vmImage: 'ubuntu-16.04' + strategy: + matrix: + Node6: + NODE_VERSION: '6.x' + NPM_INSTALL: true + Node8: + NODE_VERSION: '8.x' + NPM_INSTALL: true + Node10: + NODE_VERSION: '10.x' + Lint: + NODE_VERSION: '10.x' + LINT: true + SKIP_TESTS: true + steps: + - template: .azure-pipelines-steps.yml + +- job: Windows + pool: + vmImage: 'vs2017-win2016' + strategy: + matrix: + Node10: + NODE_VERSION: '10.x' + steps: + - script: git config --global core.symlinks true + displayName: 'Preserve symbolic links on check out' + - template: .azure-pipelines-steps.yml + +- job: Mac + pool: + vmImage: 'macOS-10.13' + strategy: + matrix: + Node10: + NODE_VERSION: '10.x' + steps: + - template: .azure-pipelines-steps.yml diff --git a/Readme.md b/Readme.md index 7e09c21ec..f0a7348c8 100644 --- a/Readme.md +++ b/Readme.md @@ -2,6 +2,7 @@ [![Build Status](https://api.travis-ci.org/tj/commander.js.svg?branch=master)](http://travis-ci.org/tj/commander.js) +[![Azure Pipelines Build Status](https://dev.azure.com/commanderjs/commander.js/_apis/build/status/commander.js-CI?branchName=master)](https://dev.azure.com/commanderjs/commander.js/_build/latest?definitionId=1&branchName=master) [![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander) [![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://npmcharts.com/compare/commander?minimal=true) [![Install Size](https://packagephobia.now.sh/badge?p=commander)](https://packagephobia.now.sh/result?p=commander) diff --git a/Readme_zh-CN.md b/Readme_zh-CN.md index f91d2d5c6..ad30c514f 100644 --- a/Readme_zh-CN.md +++ b/Readme_zh-CN.md @@ -2,6 +2,7 @@ [![Build Status](https://api.travis-ci.org/tj/commander.js.svg)](http://travis-ci.org/tj/commander.js) +[![Azure Pipelines Build Status](https://dev.azure.com/commanderjs/commander.js/_apis/build/status/commander.js-CI?branchName=master)](https://dev.azure.com/commanderjs/commander.js/_build/latest?definitionId=1&branchName=master) [![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander) [![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander) [![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/test/run.js b/test/run.js index 45ddce056..445169752 100644 --- a/test/run.js +++ b/test/run.js @@ -3,6 +3,7 @@ const { spawnSync } = require('child_process') const { readdirSync } = require('fs') const { extname, join } = require('path') +const { isSkipped } = require('./utils.js'); process.env.NODE_ENV = 'test'; @@ -13,7 +14,11 @@ readdirSync(__dirname).forEach((file) => { process.stdout.write(`\x1b[90m ${file}\x1b[0m `); const result = spawnSync(process.argv0, [ join('test', file) ]); if (result.status === 0) { - process.stdout.write('\x1b[36m✓\x1b[0m\n'); + if (isSkipped(result.stdout)) { + process.stdout.write('\x1b[33mSKIPPED\x1b[0m\n'); + } else { + process.stdout.write('\x1b[36m✓\x1b[0m\n'); + } } else { process.stdout.write('\x1b[31m✖\x1b[0m\n'); console.error(result.stderr.toString('utf8')); diff --git a/test/test.command.executableSubcommand.js b/test/test.command.executableSubcommand.js index 2dae6b7bf..459064fc5 100644 --- a/test/test.command.executableSubcommand.js +++ b/test/test.command.executableSubcommand.js @@ -1,10 +1,9 @@ var exec = require('child_process').exec , path = require('path') - , should = require('should'); + , should = require('should') + , utils = require('./utils.js'); - - -var bin = path.join(__dirname, './fixtures/pm') +var bin = 'node ' + path.join(__dirname, './fixtures/pm') // not exist exec(bin + ' list', function (error, stdout, stderr) { //stderr.should.equal('\n pm-list(1) does not exist, try --help\n\n'); @@ -25,11 +24,16 @@ exec(bin + ' publish', function (error, stdout, stderr) { // spawn EACCES exec(bin + ' search', function (error, stdout, stderr) { // TODO error info are not the same in between