From 7efc471afb0acabe819364f1a036f319204c2bed Mon Sep 17 00:00:00 2001 From: Eugene Sharygin Date: Tue, 30 Sep 2014 02:41:40 +0400 Subject: [PATCH] Simplify build process and published packages --- .gitignore | 1 + .npmignore | 3 ++ Makefile | 4 +- README.md | 4 +- lib/string-format.js | 89 ---------------------------------------- package.json | 4 ++ scripts/prepublish | 11 ----- src/string-format.coffee | 2 - 8 files changed, 11 insertions(+), 107 deletions(-) create mode 100644 .npmignore delete mode 100644 lib/string-format.js delete mode 100755 scripts/prepublish diff --git a/.gitignore b/.gitignore index 2ccbe46..ca54677 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +/lib/ /node_modules/ diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..3ab9186 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +/src/ +/test/ +/Makefile diff --git a/Makefile b/Makefile index adbc7a5..3786b61 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ COFFEE = node_modules/.bin/coffee MOCHA = node_modules/.bin/mocha --compilers coffee:coffee-script/register -XYZ = node_modules/.bin/xyz --message X.Y.Z --tag X.Y.Z --repo git@github.com:davidchambers/string-format.git --script scripts/prepublish +XYZ = node_modules/.bin/xyz --message X.Y.Z --tag X.Y.Z --repo git@github.com:davidchambers/string-format.git SRC = $(shell find src -name '*.coffee') LIB = $(patsubst src/%.coffee,lib/%.js,$(SRC)) @@ -30,8 +30,6 @@ release-major release-minor release-patch: .PHONY: setup setup: npm install - make clean - git update-index --assume-unchanged -- $(LIB) .PHONY: test diff --git a/README.md b/README.md index 556a948..0af3a32 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,8 @@ greet("Steve", 1) ### Running the test suite - make setup - make test + npm install + npm test [1]: http://docs.python.org/library/stdtypes.html#str.format diff --git a/lib/string-format.js b/lib/string-format.js deleted file mode 100644 index 3f73ad2..0000000 --- a/lib/string-format.js +++ /dev/null @@ -1,89 +0,0 @@ -// Generated by CoffeeScript 1.6.3 -(function() { - var ValueError, format, lookup, resolve, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __slice = [].slice; - - ValueError = (function(_super) { - __extends(ValueError, _super); - - function ValueError(message) { - this.message = message; - } - - ValueError.prototype.name = 'ValueError'; - - return ValueError; - - })(Error); - - format = function() { - var args, explicit, idx, implicit, message, template; - template = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - idx = 0; - explicit = implicit = false; - message = 'cannot switch from {} to {} numbering'; - return template.replace(/([{}])\1|[{](.*?)(?:!(.+?))?[}]/g, function(match, literal, key, transformer) { - var fn, value, _ref, _ref1; - if (literal) { - return literal; - } - if (key.length) { - explicit = true; - if (implicit) { - throw new ValueError(message.format('implicit', 'explicit')); - } - value = (_ref = lookup(args, key)) != null ? _ref : ''; - } else { - implicit = true; - if (explicit) { - throw new ValueError(message.format('explicit', 'implicit')); - } - value = (_ref1 = args[idx++]) != null ? _ref1 : ''; - } - if (fn = format.transformers[transformer]) { - return fn(value); - } else { - return value; - } - }); - }; - - lookup = function(object, key) { - var match; - if (!/^(\d+)([.]|$)/.test(key)) { - key = '0.' + key; - } - while (match = /(.+?)[.](.+)/.exec(key)) { - object = resolve(object, match[1]); - key = match[2]; - } - return resolve(object, key); - }; - - resolve = function(object, key) { - var value; - value = object[key]; - if (typeof value === 'function') { - return value.call(object); - } else { - return value; - } - }; - - String.prototype.format = function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - return format.apply(null, [this].concat(__slice.call(args))); - }; - - String.prototype.format.transformers = format.transformers = {}; - - String.prototype.format.version = format.version = '0.2.1'; - - if (typeof module !== "undefined" && module !== null) { - module.exports = format; - } - -}).call(this); diff --git a/package.json b/package.json index 11e1d69..d119642 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "author": "David Chambers ", "keywords": ["string", "formatting", "language", "util"], "main": "./lib/string-format", + "scripts": { + "prepublish": "make clean && make", + "test": "make test" + }, "homepage": "https://github.com/davidchambers/string-format", "bugs": "https://github.com/davidchambers/string-format/issues", "licenses": [{ diff --git a/scripts/prepublish b/scripts/prepublish deleted file mode 100755 index b008e80..0000000 --- a/scripts/prepublish +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -sed -i '' "s/version = '[^']*'/version = '$VERSION'/" src/string-format.coffee -git add src/string-format.coffee - -rm -f lib/string-format.js -make lib/string-format.js -git update-index --no-assume-unchanged lib/string-format.js -git add lib/string-format.js -git update-index --assume-unchanged lib/string-format.js diff --git a/src/string-format.coffee b/src/string-format.coffee index 80ed0e3..62fceb8 100644 --- a/src/string-format.coffee +++ b/src/string-format.coffee @@ -42,7 +42,5 @@ String::format = (args...) -> format this, args... String::format.transformers = format.transformers = {} -String::format.version = format.version = '0.2.1' - module?.exports = format