Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replace buster.promise with when.js

  • Loading branch information...
commit b510bf54504b55a720dffe8efdc9b943d444c600 1 parent 2f186ab
Magnar Sveen authored
8 lib/jslint-linter.js
... ... @@ -1,6 +1,6 @@
1 1 var fs = require('fs');
  2 +var when = require("when");
2 3 var EventEmitter = require('events').EventEmitter;
3   -var busterPromise = require('buster-promise');
4 4 var checkedFile = require('./checked-file');
5 5
6 6 function check(file, fileName) {
@@ -16,9 +16,9 @@ function checkFile(promise, fileName, err, file) {
16 16
17 17 function loadAndCheckFile(fileName) {
18 18 var self = this;
19   - var promise = busterPromise.create();
20   - fs.readFile(fileName, 'utf-8', checkFile.bind(this, promise, fileName));
21   - return promise;
  19 + var d = when.defer();
  20 + fs.readFile(fileName, 'utf-8', checkFile.bind(this, d, fileName));
  21 + return d.promise;
22 22 }
23 23
24 24 function create(options) {
33 lib/lint-scanner.js
... ... @@ -1,6 +1,5 @@
1 1 var _ = require('underscore');
2   -var busterPromise = require('buster-promise');
3   -var all = busterPromise.all;
  2 +var when = require("when");
4 3 var print = require('./print');
5 4
6 5 function fileStartsWith(start) {
@@ -36,24 +35,24 @@ function handleGlobError(path) {
36 35 }
37 36
38 37 function globPath(path) {
39   - var promise = busterPromise.create();
  38 + var d = when.defer();
40 39 this.glob(path, function (err, files) {
41 40 if (err || files.length === 0) {
42 41 handleGlobError(path);
43   - promise.reject();
  42 + d.reject();
44 43 } else {
45   - promise.resolve(files);
  44 + d.resolve(files);
46 45 }
47 46 });
48   - return promise;
  47 + return d.promise;
49 48 }
50 49
51 50 function findAllFiles(paths) {
52   - var promise = busterPromise.create();
53   - all(paths.map(globPath.bind(this))).then(function () {
54   - promise.resolve(_.flatten(arguments));
  51 + var d = when.defer();
  52 + when.all(paths.map(globPath.bind(this))).then(function () {
  53 + d.resolve(_.flatten(arguments));
55 54 });
56   - return promise;
  55 + return d.promise;
57 56 }
58 57
59 58 function filterExcludedFiles(files) {
@@ -70,23 +69,23 @@ function checkLint(file) {
70 69 }
71 70
72 71 function checkFiles(files) {
73   - var promise = busterPromise.create();
74   - all(files.map(checkLint.bind(this))).then(function () {
75   - promise.resolve();
  72 + var d = when.defer();
  73 + when.all(files.map(checkLint.bind(this))).then(function () {
  74 + d.resolve();
76 75 });
77   - return promise;
  76 + return d.promise;
78 77 }
79 78
80 79 function scan(paths) {
81   - var promise = busterPromise.create();
  80 + var d = when.defer();
82 81 var self = this;
83 82 self.findAllFiles(paths).then(function (files) {
84 83 files = self.filterExcludedFiles(files);
85 84 self.checkFiles(files).then(function () {
86   - promise.resolve();
  85 + d.resolve();
87 86 });
88 87 });
89   - return promise;
  88 + return d.promise;
90 89 }
91 90
92 91 module.exports = {
77 package.json
... ... @@ -1,42 +1,39 @@
1 1 {
2   - "name": "autolint",
3   - "version": "1.0.3",
4   - "main": "./lib/autolint",
5   - "description": "Autolint watches your files for jslint-errors.",
6   - "author": "Magnar Sveen <magnars@gmail.com>",
7   - "repository": {
8   - "type": "git",
9   - "url": "https://github.com/magnars/autolint.git"
10   - },
11   - "homepage": "https://github.com/magnars/autolint",
12   - "scripts": {
13   - "test": "buster test"
14   - },
15   - "engines": {
16   - "node": "~0.6"
17   - },
18   - "bin": {
19   - "autolint": "./bin/autolint"
20   - },
21   - "dependencies": {
22   - "glob": "~3.0",
23   - "growl": "~1.1",
24   - "underscore": "~1.1",
25   - "buster-promise": "~0.3"
26   - },
27   - "devDependencies": {
28   - "buster": "~0.3"
29   - },
30   - "keywords": [
31   - "JavaScript",
32   - "lint",
33   - "jslint",
34   - "jshint"
35   - ],
36   - "licenses": [
37   - {
38   - "type": "Modified MIT / BSD",
39   - "url": "https://github.com/magnars/autolint/blob/master/LICENSE"
40   - }
41   - ]
  2 + "name": "autolint",
  3 + "version": "1.0.3",
  4 + "main": "./lib/autolint",
  5 + "description": "Autolint watches your files for jslint-errors.",
  6 + "author": "Magnar Sveen <magnars@gmail.com>",
  7 + "repository": {
  8 + "type": "git",
  9 + "url": "https://github.com/magnars/autolint.git"
  10 + },
  11 + "homepage": "https://github.com/magnars/autolint",
  12 + "scripts": {
  13 + "test": "buster test"
  14 + },
  15 + "engines": {
  16 + "node": "~0.6"
  17 + },
  18 + "bin": {
  19 + "autolint": "./bin/autolint"
  20 + },
  21 + "dependencies": {
  22 + "glob": "~3.0",
  23 + "growl": "~1.1",
  24 + "underscore": "~1.1",
  25 + "when": "https://github.com/cujojs/when/tarball/1.0.2"
  26 + },
  27 + "keywords": [
  28 + "JavaScript",
  29 + "lint",
  30 + "jslint",
  31 + "jshint"
  32 + ],
  33 + "licenses": [
  34 + {
  35 + "type": "Modified MIT / BSD",
  36 + "url": "https://github.com/magnars/autolint/blob/master/LICENSE"
  37 + }
  38 + ]
42 39 }
7 test/lint-scanner-test.js
... ... @@ -1,4 +1,5 @@
1 1 var buster = require('buster');
  2 +var when = require("when");
2 3 var EventEmitter = require('events').EventEmitter;
3 4 var print = require('../lib/print');
4 5
@@ -104,7 +105,7 @@ buster.testCase("lintScanner", {
104 105
105 106 "checkFiles": {
106 107 setUp: function () {
107   - this.promise = buster.promise.create();
  108 + this.promise = when.defer();
108 109 this.linter.checkFile = this.stub().returns(this.promise);
109 110 },
110 111
@@ -130,8 +131,8 @@ buster.testCase("lintScanner", {
130 131
131 132 "scan": {
132 133 setUp: function () {
133   - this.findPromise = buster.promise.create();
134   - this.checkPromise = buster.promise.create();
  134 + this.findPromise = when.defer();
  135 + this.checkPromise = when.defer();
135 136 this.stub(this.scanner, 'findAllFiles').returns(this.findPromise);
136 137 this.stub(this.scanner, 'checkFiles').returns(this.checkPromise);
137 138 },

0 comments on commit b510bf5

Please sign in to comment.
Something went wrong with that request. Please try again.