Socket
Socket
Sign inDemoInstall

buddy

Package Overview
Dependencies
59
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.3 to 0.3.4

16

lib/file.js

@@ -19,3 +19,2 @@ var CSSFile, File, JSFile, fs, log, path;

this.contents = null;
this.contentsModule = null;
this.compile = false;

@@ -62,15 +61,14 @@ this.lastChange = null;

JSFile.prototype.updateContents = function(contents) {
this.contents = this.compile ? contents : "`" + contents + "`";
this.contents = contents;
return this.dependencies = this._getModuleDependencies();
};
JSFile.prototype.wrap = function() {
var contents, indent, _ref;
contents = this.contents;
if (!this.RE_MODULE.test(this.contents)) {
if (this.compile) {
indent = ((_ref = contents.match(this.RE_INDENT_WHITESPACE)) != null ? _ref[1] : void 0) || '\t';
JSFile.prototype.wrap = function(contents, isJS, escape) {
var indent, _ref;
if (!this.RE_MODULE.test(contents)) {
indent = ((_ref = contents.match(this.RE_INDENT_WHITESPACE)) != null ? _ref[1] : void 0) || '\t';
if (!isJS) {
contents = "require.module '" + this.module + "', (module, exports, require) ->\n" + (contents.replace(this.RE_LINE_BEGIN, indent)) + "\n\n" + (this.main ? "require('" + this.module + "')" : '');
} else {
contents = "`require.module('" + this.module + "', function(module, exports, require) {\n" + contents + "\n});\n\n" + (this.main ? "require('" + this.module + "');" : '') + "`";
contents = "" + (escape ? '`' : '') + "require.module('" + this.module + "', function(module, exports, require) {\n" + (contents.replace(this.RE_LINE_BEGIN, indent)) + "\n});\n\n" + (this.main ? "require('" + this.module + "');" : '') + (escape ? '`' : '');
}

@@ -77,0 +75,0 @@ }

@@ -79,3 +79,12 @@ var CSSTarget, JSTarget, Target, coffee, file, fs, growl, less, log, path, stylus, term, uglify;

dir = path.dirname(filepath);
if (!path.existsSync(dir)) return fs.mkdirSync(dir, 0777);
if (!path.existsSync(dir)) {
try {
return fs.statSync(dir).isDirectory();
} catch (error) {
if (error.code === 'ENOENT') {
this._makeDirectory(dir);
return fs.mkdirSync(dir, 0777);
}
}
}
};

@@ -138,7 +147,8 @@

filepath = path.extname(this.output).length ? this.output : path.join(this.output, f.name) + this.EXTENSION;
content = this.nodejs ? f.contents : f.wrap();
if (f.compile) {
this._compile(content, filepath, false);
content = f.compile ? this._compile(f.contents, filepath) : f.contents;
if (content) {
if (!this.nodejs) content = f.wrap(content, true, false);
this._writeFile(content, filepath, false);
} else {
this._writeFile(content, filepath, false);
return null;
}

@@ -155,19 +165,19 @@ }

f = _ref2[_j];
contents.push(f.wrap());
contents.push(f.wrap(f.contents, !f.compile, true));
}
return this._compile(contents.join('\n\n'), this.output, true);
content = this._compile(contents.join('\n\n'), this.output);
if (content) {
this._writeFile(this._wrap(content), this.output, true);
return true;
} else {
return null;
}
}
};
JSTarget.prototype._compile = function(content, filepath, header) {
var compiled;
JSTarget.prototype._compile = function(content, filepath) {
try {
compiled = coffee.compile(content, {
return coffee.compile(content, {
bare: true
});
if (compiled) {
return this._writeFile(compiled, filepath, header);
} else {
return null;
}
} catch (error) {

@@ -204,2 +214,6 @@ this._notifyError(filepath, error);

JSTarget.prototype._wrap = function(contents) {
return "(function () {\n" + (contents.replace(file.JSFile.prototype.RE_LINE_BEGIN, ' ')) + "\n}).call(this);";
};
JSTarget.prototype._addHeader = function(content) {

@@ -206,0 +220,0 @@ return "" + this.BUILT_HEADER + (new Date().toString()) + "*/\n" + content;

{
"name": "buddy",
"description": "A build framework for the compilation of higher order js/css languages (coffeescript/stylus/less).",
"version": "0.3.3",
"version": "0.3.4",
"author": "popeindustries <alex@pope-industries.com>",

@@ -6,0 +6,0 @@ "keywords": ["javascript", "coffeescript", "styus", "less"],

# Buddy
Buddy is primarily a build framework for the compilation of higher order js/css languages (coffeescript/stylus/less).
Additionally, however, by using Node.js-style module wrapping and syntax, Buddy helps you write the same style of code for server and client.
Additionally, by using Node.js-style module wrapping and syntax, Buddy helps you write the same style of code for server and client.
This modular approach promotes better js code organization, and allows for automatic concatenation (and optional minification) of code for more efficient delivery to the browser.

@@ -21,2 +21,4 @@

$ buddy compile
# compile and minify all source files
$ buddy -c compile
# watch for source changes and compile

@@ -74,3 +76,3 @@ $ buddy watch

**Project Root**: The directory from which all paths are resolved to. Determined by location of the *buddy.json* config file.
**Project Root**: The directory from which all paths resolve to. Determined by location of the *buddy.json* config file.

@@ -86,12 +88,12 @@ **Sources**: An array of directories from which all referenced files are retrieved from.

-*in*: file or directory to build. If js/coffee file, all dependencies referenced will be concatenated together for output (mixed js/coffee sources are possible).
If directory, all coffee/stylus/less files will be compiled and output to individual js/css files. Paths are relative to one of the source directories listed in *sources*.
- *in*: file or directory to build. If js/coffee file, all dependencies referenced will be concatenated together for output (mixed js/coffee sources are possible).
If directory, all coffee/stylus/less files will be compiled and output to individual js/css files.
-*out*: file or directory to output to. Paths are relative to one of the source directories listed in *sources*.
- *out*: file or directory to output to.
-*targets*: a nested target that prevents the duplication of js source code with it's parent target.
- *targets*: a nested target that prevents the duplication of js source code with it's parent target.
-*nodejs*: a flag to prevent coffee files from being wrapped with a module declaration.
- *nodejs*: a flag to prevent coffee files from being wrapped with a module declaration.
**Modules**: Each coffee-script/js file is wrapped in a module declaration based on the file location.
**Modules**: Each coffee/js file is wrapped in a module declaration based on the file's location.
Dependencies (and concatenation order) are determined by the use of ***require*** statements:

@@ -102,5 +104,7 @@

var SomeClass = require('../some_class'); // in parent package
var util = require('utils/util'); // from root package
lib.doSomething();
var something = new SomeClass();
util.log('hey');
```

@@ -183,3 +187,3 @@

"in": "src/coffee/widget.coffee", <--references some of the same sources as main.coffee
"out": "js" <--includes only referenced sources that are not included main.js
"out": "js" <--includes only referenced sources not in main.js
}

@@ -186,0 +190,0 @@ ]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc