Skip to content

Commit

Permalink
rebase and fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twokul committed Jun 19, 2016
1 parent 3dab48e commit 694d7fb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
2 changes: 2 additions & 0 deletions lib/commands/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ module.exports = Command.extend({
dryRun: commandOptions.dryRun
})
.then(function(opts) {
initCommand.project.root = process.cwd();

return initCommand
.run(commandOptions, rawArgs)
.catch(function(err) {
Expand Down
9 changes: 5 additions & 4 deletions lib/tasks/bower-install.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';

// Runs `bower install` in cwd
var existsSync = require('exists-sync');
var Promise = require('../ext/promise');
var Task = require('../models/task');
var path = require('path');
var existsSync = require('exists-sync');
var Promise = require('../ext/promise');
var Task = require('../models/task');

module.exports = Task.extend({
init: function() {
Expand All @@ -15,7 +16,7 @@ module.exports = Task.extend({
run: function(options) {
var chalk = require('chalk');
var bower = this.bower;
var bowerJson = this.project.root + '/bower.json';
var bowerJson = path.join(this.project.root, '/bower.json');
var bowerConfig = this.bowerConfig;
var ui = this.ui;
var packages = options.packages || [];
Expand Down
10 changes: 5 additions & 5 deletions lib/tasks/npm-install.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
'use strict';

// Runs `npm install` in cwd
var path = require('path');
var existsSync = require('exists-sync');
var NpmTask = require('./npm-task');
var path = require('path');
var existsSync = require('exists-sync');
var NpmTask = require('./npm-task');

module.exports = NpmTask.extend({
command: 'install',
startProgressMessage: 'Installing packages for tooling via npm',
completionMessage: 'Installed packages for tooling via npm.',
run: function(){
run: function() {
var ui = this.ui;
var packageJson = path.join(this.project.root, 'package.json');
if (!existsSync(packageJson)) {

if (!existsSync(packageJson)) {
ui.writeWarnLine('Skipping npm install: package.json not found');
return;
} else {
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/tasks/bower-install-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ describe('bower install task', function() {
beforeEach(function() {
var project = new MockProject();
ui = new MockUI();

bowerInstallTask = new BowerInstallTask({
ui: ui,
project: project
});
});

afterEach(function() {
ui = undefined;
bowerInstallTask = undefined;
});

it('skips bower installs if there is no bower.json', function() {
bowerInstallTask.run({});
expect(ui.output).to.include('Skipping bower install: bower.json not found');
});
});
});
20 changes: 12 additions & 8 deletions tests/unit/tasks/npm-install-test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
'use strict';

var NpmInstallTask = require('../../../lib/tasks/npm-install');
var MockUI = require('../../helpers/mock-ui');
var MockProject = require('../../helpers/mock-project');
var expect = require('chai').expect;

var MockUI = require('../../helpers/mock-ui');
var expect = require('chai').expect;

describe('npm install task', function() {
var npmInstallTask;
var ui;

beforeEach(function() {
var project = new MockProject({});
project.root = './tmp';

var project = {
root: __dirname
};
ui = new MockUI();

npmInstallTask = new NpmInstallTask({
ui: ui,
project: project
});
});

afterEach(function() {
ui = undefined;
npmInstallTask = undefined;
});

it('skips npm installs if there is no package.json', function() {
npmInstallTask.run({});
expect(ui.output).to.include('Skipping npm install: package.json not found');
});
});
});

0 comments on commit 694d7fb

Please sign in to comment.