Skip to content

Commit

Permalink
t2 init: detectLanguage => resolveLanguage (matches deployment)
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jun 22, 2016
1 parent 94ba7b6 commit d700d68
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exportables.initProject = (opts) => {
opts.directory = opts.directory || path.resolve('.');

// Detect the requested language
var lang = exportables.detectLanguage(opts);
var lang = exportables.resolveLanguage(opts);

// If a language could not be detected
if (lang === null) {
Expand All @@ -31,7 +31,7 @@ exportables.initProject = (opts) => {
};

// Determine the langauge to initialize the project with
exportables.detectLanguage = (opts) => {
exportables.resolveLanguage = (opts) => {

// If somehow a language option wasn't provided
if (!opts.lang) {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/bin-tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ exports['Tessel (init)'] = {
this.successfulCommand = this.sandbox.stub(cli, 'closeSuccessfulCommand');
this.failedCommand = this.sandbox.stub(cli, 'closeFailedCommand');
this.initProject = this.sandbox.spy(controller, 't2Init');
this.detectLanguage = this.sandbox.spy(init, 'detectLanguage');
this.resolveLanguage = this.sandbox.spy(init, 'resolveLanguage');
this.generateJavaScriptProject = this.sandbox.stub(init.js, 'generateProject').returns(Promise.resolve());
this.generateRustProject = this.sandbox.stub(init.rs, 'generateProject').returns(Promise.resolve());
done();
Expand All @@ -933,7 +933,7 @@ exports['Tessel (init)'] = {
// Ensure it calls our internal init function
test.equal(this.initProject.callCount, 1);
// Ensure it checks the language being requested
test.equal(this.detectLanguage.callCount, 1);
test.equal(this.resolveLanguage.callCount, 1);
// It should generate a js project
test.equal(this.generateJavaScriptProject.callCount, 1);
// It should not generate a Rust project
Expand All @@ -953,7 +953,7 @@ exports['Tessel (init)'] = {
// Ensure it calls our internal init function
test.equal(this.initProject.callCount, 1);
// Ensure it checks the language being requested
test.equal(this.detectLanguage.callCount, 1);
test.equal(this.resolveLanguage.callCount, 1);
// Ensure it does not attempt to generate a Rust project
test.equal(this.generateJavaScriptProject.callCount, 0);
// Ensure it does generate a Rust project
Expand Down
24 changes: 12 additions & 12 deletions test/unit/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,53 @@ exports['init (language args)'] = {
javascriptArgs: function(test) {
test.expect(4);
// No language arg indicates JavaScript by default
test.ok(init.detectLanguage({}) === init.js);
test.ok(init.resolveLanguage({}) === init.js);
// Can request JavaScript with explicit name
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'javascript'
}) === init.js);
// Can request JavaScript with abbr
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'js'
}) === init.js);
// This won't request JavaScript init
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'something else'
}) !== init.js);
test.done();
},
rustArgs: function(test) {
test.expect(4);
// No language arg does not mean Rust
test.ok(init.detectLanguage({}) !== init.rs);
test.ok(init.resolveLanguage({}) !== init.rs);
// Can request Rust with explicit name
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'rust'
}) === init.rs);
// Can request Rust with abbr
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'rs'
}) === init.rs);
// This won't request Rust init
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'whitespace'
}) !== init.rs);
test.done();
},
pythonArgs: function(test) {
test.expect(4);
// No language arg does not mean Rust
test.ok(init.detectLanguage({}) !== init.py);
test.ok(init.resolveLanguage({}) !== init.py);
// Can request Rust with explicit name
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'python'
}) === init.py);
// Can request Rust with abbr
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'py'
}) === init.py);
// This won't request Rust init
test.ok(init.detectLanguage({
test.ok(init.resolveLanguage({
lang: 'morse-code'
}) !== init.py);
test.done();
Expand Down

0 comments on commit d700d68

Please sign in to comment.