From 2fc08e6d05841be50e4dcb7eb89680026144d930 Mon Sep 17 00:00:00 2001 From: Dave Wasmer Date: Thu, 8 Feb 2018 14:46:17 -0700 Subject: [PATCH] fix: fix tests --- lib/project.ts | 2 +- lib/spinner.ts | 8 ++++---- lib/utils/globify.ts | 2 +- package.json | 8 ++++---- test/acceptance/commands/addon-test.ts | 14 +++++++++++--- test/acceptance/commands/new-test.ts | 16 ++++++++++++---- tslint.json | 3 --- 7 files changed, 33 insertions(+), 20 deletions(-) diff --git a/lib/project.ts b/lib/project.ts index 3b82f37..219ee9d 100644 --- a/lib/project.ts +++ b/lib/project.ts @@ -101,7 +101,7 @@ export default class Project { const Broccoli = require('broccoli').Builder; let broccoli = new Broccoli(tree); let results = await broccoli.build(); - await this.finishBuild(results, destDir); + this.finishBuild(results, destDir); debug('project build finished'); spinner.succeed(`${ this.pkg.name } build complete (${ timer.stop() }s)`); } catch (err) { diff --git a/lib/spinner.ts b/lib/spinner.ts index ea94f3f..22e4f9c 100644 --- a/lib/spinner.ts +++ b/lib/spinner.ts @@ -64,7 +64,7 @@ function flushQueue() { childChannel.ref(); try { childSpinner.send(nextOperation); - } catch(e) { + } catch (e) { // most likely the child process is dead because it // received the sigint while this process was blocked // on some build step - we're likely about to shut @@ -89,9 +89,9 @@ export function wrapOutputStream(stream: Writable) { if (spinnerIsActive) { readline.clearLine(mockOriginalStream, 0); readline.cursorTo(mockOriginalStream, 0); - chunk = chunk.toString(); - if (!chunk.endsWith('\n')) { - chunk = chunk + '\n'; + let chunkStr = chunk.toString(); + if (!chunkStr.endsWith('\n')) { + chunkStr = `${ chunkStr }\n`; } } return originalWrite(chunk, encoding, callback); diff --git a/lib/utils/globify.ts b/lib/utils/globify.ts index 636cad3..cb00a8a 100644 --- a/lib/utils/globify.ts +++ b/lib/utils/globify.ts @@ -1,3 +1,3 @@ export default function globify(dirs: string[]) { return dirs.map((dir) => `${ dir }/**/*`); -} \ No newline at end of file +} diff --git a/package.json b/package.json index aa6815f..4c8d3d1 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,20 @@ { "name": "denali-cli", "version": "0.0.20", - "description": "The official CLI for starting, building, and running Denali apps and addons", + "description": "The official CLI for creating, building, and running Denali apps and addons", "homepage": "http://denali.js.org", "repository": "denali-js/denali-cli", "author": { "name": "Dave Wasmer", "email": "davewasmer@gmail.com", - "url": "davewasmer.com" + "url": "http://davewasmer.com" }, "bin": { "denali": "dist/bin/denali" }, "main": "dist/lib/index.js", "engines": { - "node": ">=7" + "node": ">=7.6" }, "files": [ "dist" @@ -41,7 +41,7 @@ "build:bin": "mv dist/bin/denali.js dist/bin/denali && chmod +x dist/bin/denali", "build:templates": "cp -r lib/templates dist/lib/templates", "prepublishOnly": "npm run build", - "lint": "! tslint --project tsconfig.json -c tslint.json --type-check | sed \"s|$PWD/||\" | grep ERROR", + "lint": "! tslint --project tsconfig.json -c tslint.json | sed \"s|$PWD/||\" | grep ERROR", "test": "npm run lint && npm run build && nyc ava dist/test/acceptance" }, "license": "MIT", diff --git a/test/acceptance/commands/addon-test.ts b/test/acceptance/commands/addon-test.ts index 4e0cf02..1877746 100644 --- a/test/acceptance/commands/addon-test.ts +++ b/test/acceptance/commands/addon-test.ts @@ -3,17 +3,25 @@ import test from 'ava'; import { each } from 'lodash'; import * as path from 'path'; import * as fs from 'fs-extra'; +import * as tmp from 'tmp'; import CliAcceptanceTest from '../../utils/cli-acceptance'; test('generates an addon', async (t) => { - let addonCommand = new CliAcceptanceTest('addon denali-new-addon', { populateWithDummy: false, name: 'new-command' }); + let addonCommand = new CliAcceptanceTest('addon denali-new-addon', { + populateWithDummy: false, + name: 'addon-command', + dir: tmp.dirSync({ + unsafeCleanup: true, + prefix: `addon-command` + }).name + }); + await addonCommand.run({ failOnStderr: true }); + let filesToCheck = { 'app/addon.js': 'addon main file', '.gitignore': '.gitignore', 'test/dummy/app/application.js': 'dummy app file' }; - - await addonCommand.run({ failOnStderr: true }); each(filesToCheck, (description, file) => { let pathToCheck = path.join(addonCommand.dir, 'denali-new-addon', file); t.true(fs.existsSync(pathToCheck), `${ description } should be generated`); diff --git a/test/acceptance/commands/new-test.ts b/test/acceptance/commands/new-test.ts index b80a58e..06a90c1 100644 --- a/test/acceptance/commands/new-test.ts +++ b/test/acceptance/commands/new-test.ts @@ -2,14 +2,22 @@ import test from 'ava'; import * as path from 'path'; import * as fs from 'fs-extra'; +import * as tmp from 'tmp'; import CliAcceptanceTest from '../../utils/cli-acceptance'; test('generates an app', async (t) => { - let newCommand = new CliAcceptanceTest('new my-denali-app', { populateWithDummy: false, name: 'new-command' }); - let generatedFilepath = path.join(newCommand.dir, 'my-denali-app', 'app', 'application.js'); - let gitignorePath = path.join(newCommand.dir, 'my-denali-app', '.gitignore'); - + let newCommand = new CliAcceptanceTest('new my-denali-app', { + populateWithDummy: false, + name: 'new-command', + dir: tmp.dirSync({ + unsafeCleanup: true, + prefix: `new-command` + }).name + }); await newCommand.run({ failOnStderr: true }); + + let generatedFilepath = path.join(newCommand.dir, 'my-denali-app', 'app', 'application.js'); t.true(fs.existsSync(generatedFilepath), 'file should be generated'); + let gitignorePath = path.join(newCommand.dir, 'my-denali-app', '.gitignore'); t.true(fs.existsSync(gitignorePath), 'gitignore should be generated'); }); diff --git a/tslint.json b/tslint.json index ef00c47..08b1d00 100644 --- a/tslint.json +++ b/tslint.json @@ -6,7 +6,6 @@ "arrow-return-shorthand": true, "class-name": true, "comment-format": [ true, "check-space" ], - "completed-docs": [ true, "classes", "functions", "methods", "properties" ], "curly": true, "eofline": true, "import-spacing": true, @@ -32,7 +31,6 @@ "no-empty-interface": true, "no-empty": true, "no-eval": true, - "no-floating-promises": true, "no-for-in-array": true, "no-inferrable-types": [ true, "ignore-params" ], "no-internal-module": true, @@ -77,7 +75,6 @@ "variable-declaration": "onespace" } ], - "typeof-compare": true, "unified-signatures": true, "use-isnan": true, "whitespace": [ true, "check-branch", "check-decl", "check-operator", "check-module", "check-separator", "check-type" ]