-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24fdd7d
commit ce6c70e
Showing
15 changed files
with
514 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// System Objects | ||
var path = require('path'); | ||
// Third Party Dependencies | ||
|
||
// Internal | ||
var languages = { | ||
js: require('./javascript'), | ||
rs: require('./rust'), | ||
py: require('./python'), | ||
}; | ||
|
||
var exportables = {}; | ||
|
||
// Initialize the directory given the various options | ||
exportables.initProject = (opts) => { | ||
|
||
// Set a default directory if one was not provided | ||
opts.directory = opts.directory || path.resolve('.'); | ||
|
||
// Detect the requested language | ||
var lang = exportables.detectLanguage(opts); | ||
|
||
// If a language could not be detected | ||
if (lang === null) { | ||
// Return an error | ||
return Promise.reject(new Error('Unrecognized language selection.')); | ||
} else { | ||
// Otherwise generate a project in that language | ||
return lang.generateProject(opts); | ||
} | ||
}; | ||
|
||
// Determine the langauge to initialize the project with | ||
exportables.detectLanguage = (opts) => { | ||
|
||
// If somehow a language option wasn't provided | ||
if (!opts.lang) { | ||
// Return JS as default | ||
return languages['js']; | ||
} | ||
|
||
// Iterate through each of the langauges | ||
for (var key in languages) { | ||
// Pull out the language info | ||
var lang = languages[key]; | ||
|
||
// Check if the language option is within the available language keywords | ||
if (lang.meta.keywords && | ||
lang.meta.keywords.indexOf(opts.lang.toLowerCase()) > -1) { | ||
// If it is, return that language | ||
return lang; | ||
} | ||
} | ||
|
||
// If not, someone has requested a language that is not supported | ||
return null; | ||
}; | ||
|
||
module.exports = exportables; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// System Objects | ||
|
||
// Third Party Dependencies | ||
|
||
// Internal | ||
var logs = require('../logs'); | ||
|
||
var exportables = {}; | ||
|
||
exportables.meta = { | ||
keywords: ['py', 'python'] | ||
}; | ||
|
||
exportables.generateProject = () => { | ||
logs.info(`Sorry, Python project generation isn't implemented yet. Contributions welcome!`); | ||
}; | ||
|
||
module.exports = exportables; |
Oops, something went wrong.