From aec07cf103875cca1528b6e28fde215f5e75b001 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Mon, 11 Apr 2016 00:27:44 +0100 Subject: [PATCH] fix(lint): fix listing of files --- addon/ng2/commands/{lint.js => lint.ts} | 7 ++----- addon/ng2/tasks/lint.js | 22 ---------------------- addon/ng2/tasks/lint.ts | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 27 deletions(-) rename addon/ng2/commands/{lint.js => lint.ts} (69%) delete mode 100644 addon/ng2/tasks/lint.js create mode 100644 addon/ng2/tasks/lint.ts diff --git a/addon/ng2/commands/lint.js b/addon/ng2/commands/lint.ts similarity index 69% rename from addon/ng2/commands/lint.js rename to addon/ng2/commands/lint.ts index f93c3cc5eab1..76b431975605 100644 --- a/addon/ng2/commands/lint.js +++ b/addon/ng2/commands/lint.ts @@ -1,8 +1,5 @@ -/* jshint node: true */ -'use strict'; - -var Command = require('ember-cli/lib/models/command'); -var LintTask = require('../tasks/lint'); +import * as Command from 'ember-cli/lib/models/command'; +import * as LintTask from '../tasks/lint'; module.exports = Command.extend({ name: 'lint', diff --git a/addon/ng2/tasks/lint.js b/addon/ng2/tasks/lint.js deleted file mode 100644 index 4351c1f693a0..000000000000 --- a/addon/ng2/tasks/lint.js +++ /dev/null @@ -1,22 +0,0 @@ -/* jshint node: true */ -'use strict'; - -var Promise = require('ember-cli/lib/ext/promise'); -var Task = require('ember-cli/lib/models/task'); -var exec = Promise.denodeify(require('child_process').exec); - -module.exports = Task.extend({ - run: function () { - var chalk = require('chalk'); - var ui = this.ui; - - return exec('npm run lint') - .then(function () { - ui.writeLine(chalk.green('Successfully linted files.')); - }) - .catch(function (/*error*/) { - ui.writeLine(chalk.red( - 'Couldn\'t do \'npm run lint\'. Please check this script exists in your package.json.')); - }); - } -}); diff --git a/addon/ng2/tasks/lint.ts b/addon/ng2/tasks/lint.ts new file mode 100644 index 000000000000..b2e0258b3489 --- /dev/null +++ b/addon/ng2/tasks/lint.ts @@ -0,0 +1,22 @@ +import * as Promise from 'ember-cli/lib/ext/promise'; +import * as Task from 'ember-cli/lib/models/task'; +import * as chalk from 'chalk'; +import {exec} from 'child_process'; + +module.exports = Task.extend({ + run: function () { + var ui = this.ui; + + return new Promise(function(resolve) { + exec('npm run lint', (err, stdout) => { + ui.writeLine(stdout); + if (err) { + ui.writeLine(chalk.red('Lint errors found in the listed files.')); + } else { + ui.writeLine(chalk.green('All files pass linting.')); + } + resolve(); + }); + }); + } +});