Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage/**
node_modules/**
templates/**/**__name__*.js
templates/**/__name__/**/*.js
24 changes: 24 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"node": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"noarg": true,
"noempty": true,
"nonew": true,
"undef": true,
"unused": false,
"trailing": true,
"indent": 4,
"boss": true,
"eqnull": true,
"browser": true,
"globals": {
"require": false,
"exports": false,
"module": false,
"global": false
}
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_js:
- 8
script: npm run $COMMAND
env:
- COMMAND=lint
- COMMAND=test
notifications:
irc:
Expand Down
3 changes: 0 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
</copyright> */

var fs = require("fs");
var path = require("path");

var Command = require("commander").Command;

var config = require("./package.json");
Expand Down
4 changes: 2 additions & 2 deletions lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var fs = require("fs");
var path = require("path");
var MinitError = require("./error").MinitError;

var create = exports = module.exports = function(templateName, config, templateModule) {
var create = module.exports = function(templateName, config, templateModule) {

config.templateName = templateName;

Expand Down Expand Up @@ -70,7 +70,7 @@ var create = exports = module.exports = function(templateName, config, templateM
};
exports.create = create;

exports.addCommandsTo = function(program) {
exports.addCommandsTo = create.addCommandsTo = function(program) {
var templatesDir = path.join(program.minitHome, "templates");
var fileNames = fs.readdirSync(templatesDir);
fileNames.forEach(function(filename) {
Expand Down
28 changes: 14 additions & 14 deletions lib/mustache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
exports.render = render;
exports.clearCache = clearCache;

// This is here for backwards compatibility with 0.4.x.
exports.to_html = function (template, view, partials, send) {
// This is here for backwards compatibility with 0.4.x.
exports.to_html = function (template, view, partials, send) { // jshint ignore:line
var result = render(template, view, partials);

if (typeof send === "function") {
Expand Down Expand Up @@ -61,7 +61,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
var trim;
if (_trim) {
trim = function (string) {
return string == null ? "" : _trim.call(string);
return string === null || string === undefined ? "" : _trim.call(string);
};
} else {
var trimLeft, trimRight;
Expand All @@ -76,7 +76,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
}

trim = function (string) {
return string == null ? "" :
return string === null || string === undefined ? "" :
String(string).replace(trimLeft, "").replace(trimRight, "");
};
}
Expand Down Expand Up @@ -142,7 +142,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
while (j < lastIndex) {
context = context[names[j++]];

if (context == null) {
if (context === null || context === undefined) {
break;
}

Expand All @@ -160,7 +160,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
value = value.call(localStack[localStack.length - 1]);
}

if (value == null) {
if (value === null || value === undefined) {
return defaultValue;
}

Expand All @@ -175,7 +175,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
// From the spec: inverted sections may render text once based on the
// inverse value of the key. That is, they will be rendered if the key
// doesn't exist, is false, or is an empty list.
if (value == null || value === false || (isArray(value) && value.length === 0)) {
if (value === null || value === undefined || value === false || (isArray(value) && value.length === 0)) {
buffer += callback();
}
} else if (isArray(value)) {
Expand Down Expand Up @@ -294,9 +294,9 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};

var closeSection = function (source) {
var name = trim(source);
var openName = sectionStack.length != 0 && sectionStack[sectionStack.length - 1].name;
var openName = sectionStack.length !== 0 && sectionStack[sectionStack.length - 1].name;

if (!openName || name != openName) {
if (!openName || name !== openName) {
throw debug(new Error('Section named "' + name + '" was never opened'), template, line, options.file);
}

Expand Down Expand Up @@ -373,7 +373,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
callback = closeSection;
break;
case "{": // plain variable
closeTag = "}" + closeTag;
closeTag = "}" + closeTag; // jshint ignore:line
// fall through
case "&": // plain variable
i++;
Expand All @@ -399,7 +399,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};

// Maintain line count for \n in source.
var n = 0;
while (~(n = source.indexOf("\n", n))) {
while (~(n = source.indexOf("\n", n))) { // jshint ignore:line
line++;
n++;
}
Expand Down Expand Up @@ -437,7 +437,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
}
}

if (sectionStack.length != 0) {
if (sectionStack.length !== 0) {
throw debug(new Error('Section "' + sectionStack[sectionStack.length - 1].name + '" was not closed properly'), template, line, options.file);
}

Expand All @@ -455,7 +455,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
var body = code.join("").replace(/buffer \+= "";\n/g, "");

if (options.debug) {
if (typeof console != "undefined" && console.log) {
if (typeof console !== "undefined" && console.log) {
console.log(body);
} else if (typeof print === "function") {
print(body);
Expand All @@ -471,7 +471,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
function _compile(template, options) {
var args = "view,partials,stack,lookup,escapeHTML,renderSection,render";
var body = parse(template, options);
var fn = new Function(args, body);
var fn = new Function(args, body); // jshint ignore:line

// This anonymous function wraps the generated function so we can do
// argument coercion, setup some variables, and handle any errors
Expand Down
33 changes: 18 additions & 15 deletions lib/template-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ exports.TemplateBase = Object.create(Object.prototype, {

validatePackageHome: {
value: function (value) {
return new String(value)
return String(value);
}
},

Expand All @@ -74,7 +74,7 @@ exports.TemplateBase = Object.create(Object.prototype, {
var packageHome = process.cwd(),
root = qfs.root();
if (root === "") {
root = "/"
root = "/";
}
while (true) {
if (FS.existsSync(Path.join(packageHome, "package.json"))) {
Expand All @@ -86,7 +86,7 @@ exports.TemplateBase = Object.create(Object.prototype, {
break;
}
}
return packageHome
return packageHome;
}
},

Expand Down Expand Up @@ -119,13 +119,13 @@ exports.TemplateBase = Object.create(Object.prototype, {
if (exists) {
promise = qfs.removeTree(mainBuildDir)
.then(function() {
return qfs.makeDirectory(mainBuildDir)
return qfs.makeDirectory(mainBuildDir);
});
} else {
promise = qfs.makeDirectory(mainBuildDir);
}
return promise.then(function() {
return qfs.copyTree(self.directory, self.buildDir)
return qfs.copyTree(self.directory, self.buildDir);
})
.then(function() {
return self.processBuildDirectory(self.buildDir);
Expand All @@ -136,7 +136,7 @@ exports.TemplateBase = Object.create(Object.prototype, {

finalDestination: {
get: function() {
return Path.join(this.options.packageHome || "", this.options.destination || "")
return Path.join(this.options.packageHome || "", this.options.destination || "");
}
},

Expand All @@ -160,7 +160,7 @@ exports.TemplateBase = Object.create(Object.prototype, {
}
});
}));
})
});
});
}
},
Expand All @@ -169,7 +169,7 @@ exports.TemplateBase = Object.create(Object.prototype, {
value: function() {
var self = this;
return this.finish(this.finalDestination).then(function() {
return qfs.removeDirectory(self.buildDir)
return qfs.removeDirectory(self.buildDir);
});
}
},
Expand Down Expand Up @@ -216,7 +216,7 @@ exports.TemplateBase = Object.create(Object.prototype, {
var newContents = self.applyTransform(data, self.options);

return qfs.write(filename, newContents).then(function () {
return self.rename(filename)
return self.rename(filename);
}).fail(function () {
console.log("Error writing to " + filename + ".");
throw "Error writing to " + filename + ".";
Expand All @@ -233,12 +233,15 @@ exports.TemplateBase = Object.create(Object.prototype, {

rename: {
value: function(filename) {
var newName = filename;
for (var name in this.options) {
newName = newName.replace(
FILENAME_VARIABLE_START + name + FILENAME_VARIABLE_END,
this.options[name]
);
var newName = filename,
options = this.options;
for (var name in options) {
if (options.hasOwnProperty(name)) {
newName = newName.replace(
FILENAME_VARIABLE_START + name + FILENAME_VARIABLE_END,
options[name]
);
}
}
if(newName === filename) {
return Q.resolve(filename);
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@
},
"devDependencies": {
"jasmine-node": "^1.14.5",
"jshint": "^2.9.5",
"mocks": "0.0.15",
"sandboxed-module": "^0.3.0"
},
"engines": {
"node": "~0.10.2"
"node": "=>4.8.4",
"npm": "=>2.15.11"
},
"bin": {
"minit": "minit"
},
"scripts": {
"test": "node run-test.js"
"test": "node run-test.js",
"lint": "jshint ."
},
"preferGlobal": true
}
4 changes: 2 additions & 2 deletions run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jasmine.Block.prototype.execute = function (onComplete) {

jasmine.executeSpecsInFolder({
"specFolders": [__dirname+ "/test"],
"onComplete": function(runner, log){
if (runner.results().failedCount == 0) {
"onComplete": function(runner/*, log*/){
if (runner.results().failedCount === 0) {
process.exit(0);
}
else {
Expand Down
5 changes: 1 addition & 4 deletions templates/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
var PackageTemplate = require("./package").Template;
var ArgumentError = require("../lib/error.js").ArgumentError;
var path = require('path');
var fs = require('fs');
var npm = require("npm");
var Q = require('q');
var removeDiacritics = require("diacritics").remove;

var _fromCamelToDashes = function(name) {
Expand Down Expand Up @@ -62,7 +59,7 @@ exports.Template = Object.create(PackageTemplate, {
},

defaultPackageHome: {
value: function (value) {
value: function () {
return process.cwd();
}
}
Expand Down
3 changes: 0 additions & 3 deletions templates/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
</copyright> */

var ModuleTemplate = require("./module").Template;
var fs = require('fs');

var Command = require("commander").Command;

exports.Template = Object.create(ModuleTemplate, {

Expand Down
9 changes: 1 addition & 8 deletions templates/digit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
var PackageTemplate = require("./package").Template;
var ArgumentError = require("../lib/error.js").ArgumentError;
var path = require('path');
var fs = require('fs');
var npm = require("npm");
var Q = require('q');
var removeDiacritics = require("diacritics").remove;


var _fromCamelToDashes = function(name) {
var s1 = name.replace(/([A-Z])/g, function (g) { return "-"+g.toLowerCase(); });
s1 = s1.replace(/--/g, "-").replace(/^-/, "");
Expand Down Expand Up @@ -62,11 +58,8 @@ exports.Template = Object.create(PackageTemplate, {
},

defaultPackageHome: {
value: function (value) {
value: function () {
return process.cwd();
}
}



});
Loading