sentry 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +105 -0
- package/README.md +52 -60
- package/dist/bin.mjs +218 -0
- package/package.json +42 -20
- package/.gitignore +0 -4
- package/.npmignore +0 -1
- package/Cakefile +0 -12
- package/LICENSE +0 -9
- package/lib/sentry.js +0 -78
- package/spec/fixtures/bar.js +0 -1
- package/spec/fixtures/deepwildcard/bar.js +0 -1
- package/spec/fixtures/deepwildcard/deep/baz.coffee +0 -1
- package/spec/fixtures/deepwildcard/deep/foo.js +0 -1
- package/spec/fixtures/deepwildcard/deep/qux.js +0 -1
- package/spec/fixtures/regex/bar.js +0 -1
- package/spec/fixtures/regex/deep/foo.js +0 -1
- package/spec/fixtures/regex/deep/foo.txt +0 -1
- package/spec/fixtures/string/bar.js +0 -1
- package/spec/fixtures/string/baz.js +0 -1
- package/spec/fixtures/string/foo.js +0 -1
- package/spec/fixtures/wildcard/bar.js +0 -1
- package/spec/fixtures/wildcard/baz.coffee +0 -1
- package/spec/fixtures/wildcard/foo.js +0 -1
- package/spec/fixtures/wildcard/qux.js +0 -1
- package/spec/helpers/spec_helper.coffee +0 -8
- package/spec/sentry_spec.coffee +0 -170
- package/src/sentry.coffee +0 -81
package/package.json
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sentry",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"recursive"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Sentry CLI - A command-line interface for using Sentry built by robots and humans for robots and humans",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sentry": "./dist/bin.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/bin.mjs"
|
|
12
11
|
],
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "bun run src/bin.ts",
|
|
14
|
+
"build": "bun run script/build.ts --single",
|
|
15
|
+
"build:all": "bun run script/build.ts",
|
|
16
|
+
"bundle": "bun run script/bundle.ts",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"lint": "bunx ultracite check",
|
|
19
|
+
"lint:fix": "bunx ultracite fix",
|
|
20
|
+
"test": "bun test",
|
|
21
|
+
"test:e2e": "bun test test/e2e"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"
|
|
24
|
+
"@biomejs/biome": "2.3.8",
|
|
25
|
+
"@stricli/auto-complete": "^1.2.4",
|
|
26
|
+
"@stricli/core": "^1.2.4",
|
|
27
|
+
"@types/bun": "latest",
|
|
28
|
+
"@types/node": "^22",
|
|
29
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
30
|
+
"chalk": "^5.6.2",
|
|
31
|
+
"esbuild": "^0.25.0",
|
|
32
|
+
"ky": "^1.14.2",
|
|
33
|
+
"qrcode-terminal": "^0.12.0",
|
|
34
|
+
"tinyglobby": "^0.2.15",
|
|
35
|
+
"typescript": "^5",
|
|
36
|
+
"ultracite": "6.3.10",
|
|
37
|
+
"zod": "^3.24.0"
|
|
21
38
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
}
|
|
26
|
-
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/getsentry/cli.git"
|
|
42
|
+
},
|
|
43
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22"
|
|
46
|
+
},
|
|
47
|
+
"packageManager": "bun@1.3.3"
|
|
48
|
+
}
|
package/.gitignore
DELETED
package/.npmignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/node_modules/
|
package/Cakefile
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
exec = require('child_process').exec
|
|
2
|
-
|
|
3
|
-
task 'build', 'src/ --> lib/', ->
|
|
4
|
-
exec 'coffee -co lib src', (err, stdout, stderr) ->
|
|
5
|
-
if err
|
|
6
|
-
console.log stdout
|
|
7
|
-
console.log stderr
|
|
8
|
-
throw new Error "Error while compiling .coffee to .js"
|
|
9
|
-
|
|
10
|
-
task 'stub', 'A stub task for testing running a child process', ->
|
|
11
|
-
console.log 'foo'
|
|
12
|
-
return 'moo'
|
package/LICENSE
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) Craig Spaeth <craigspaeth@gmail.com>, Art.sy, 2011
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/lib/sentry.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
var exec, fileUtil, findWildcardFiles, fs, path, watchFile, _;
|
|
3
|
-
fileUtil = require('file');
|
|
4
|
-
_ = require('underscore');
|
|
5
|
-
_.mixin(require('underscore.string'));
|
|
6
|
-
fs = require('fs');
|
|
7
|
-
exec = require('child_process').exec;
|
|
8
|
-
path = require('path');
|
|
9
|
-
this.watch = function(file, task, callback) {
|
|
10
|
-
var files, _i, _len, _results;
|
|
11
|
-
if (_.isFunction(task)) {
|
|
12
|
-
callback = task;
|
|
13
|
-
}
|
|
14
|
-
if (_.isRegExp(file)) {
|
|
15
|
-
console.log(path.dirname(module.parent.filename));
|
|
16
|
-
console.log(file.toString().replace(/\\\//g, '/'));
|
|
17
|
-
return fileUtil.walkSync(path.dirname(module.parent.filename), function(root, flds, fls) {
|
|
18
|
-
return console.log(fls);
|
|
19
|
-
});
|
|
20
|
-
} else if (file.indexOf('/*') !== -1) {
|
|
21
|
-
files = findWildcardFiles(file);
|
|
22
|
-
_results = [];
|
|
23
|
-
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
|
24
|
-
file = files[_i];
|
|
25
|
-
_results.push(watchFile(file, task, callback));
|
|
26
|
-
}
|
|
27
|
-
return _results;
|
|
28
|
-
} else {
|
|
29
|
-
if (!path.existsSync(file)) {
|
|
30
|
-
throw new Error("SENTRY: File '" + file + "' does not exist!");
|
|
31
|
-
}
|
|
32
|
-
return watchFile(file, task, callback);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
watchFile = function(file, task, callback) {
|
|
36
|
-
return fs.watchFile(file, function(curr, prev) {
|
|
37
|
-
if (curr.size === prev.size && curr.mtime.getTime() === prev.mtime.getTime()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (_.isString(task)) {
|
|
41
|
-
return exec('cake stub', function(err, stdout, stderr) {
|
|
42
|
-
return callback(err, stdout, stderr);
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
return callback(file);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
findWildcardFiles = function(file) {
|
|
50
|
-
var ext, files, root, _i, _len, _ref;
|
|
51
|
-
files = [];
|
|
52
|
-
if ((file != null) && file.indexOf('**/*') !== -1) {
|
|
53
|
-
root = file.split('**/*')[0];
|
|
54
|
-
ext = file.split('**/*')[1];
|
|
55
|
-
fileUtil.walkSync(root, function(root, flds, fls) {
|
|
56
|
-
var file, _i, _len, _results;
|
|
57
|
-
root = (root.charAt(root.length - 1) === '/' ? root : root + '/');
|
|
58
|
-
_results = [];
|
|
59
|
-
for (_i = 0, _len = fls.length; _i < _len; _i++) {
|
|
60
|
-
file = fls[_i];
|
|
61
|
-
_results.push((file.match(new RegExp(ext + '$')) != null) && _.indexOf(files, root + file) === -1 ? files.push(root + file) : void 0);
|
|
62
|
-
}
|
|
63
|
-
return _results;
|
|
64
|
-
});
|
|
65
|
-
} else if ((file != null) && file.indexOf('/*') !== -1) {
|
|
66
|
-
root = file.split('/*')[0];
|
|
67
|
-
ext = file.split('/*')[1];
|
|
68
|
-
_ref = fs.readdirSync(root);
|
|
69
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
70
|
-
file = _ref[_i];
|
|
71
|
-
if (file.indexOf('.') !== -1 && (file.match(new RegExp(ext + '$')) != null) && _.indexOf(files, root + '/' + file) === -1) {
|
|
72
|
-
files.push(root + '/' + file);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return files;
|
|
77
|
-
};
|
|
78
|
-
}).call(this);
|
package/spec/fixtures/bar.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World
|
package/spec/sentry_spec.coffee
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
require './helpers/spec_helper.coffee'
|
|
2
|
-
sentry = require '../src/sentry.coffee'
|
|
3
|
-
fs = require 'fs'
|
|
4
|
-
exec = require('child_process').exec
|
|
5
|
-
spawn = require('child_process').spawn
|
|
6
|
-
path = require 'path'
|
|
7
|
-
_ = require 'underscore'
|
|
8
|
-
|
|
9
|
-
describe 'sentry.watch', ->
|
|
10
|
-
|
|
11
|
-
describe 'given a relative file string', ->
|
|
12
|
-
|
|
13
|
-
it 'throws an error if it cant find the file', ->
|
|
14
|
-
try
|
|
15
|
-
sentry.watch('garbage')
|
|
16
|
-
catch e
|
|
17
|
-
expect(e.message).toEqual "SENTRY: File 'garbage' does not exist!"
|
|
18
|
-
|
|
19
|
-
it 'runs a function when the file is changed', ->
|
|
20
|
-
done = false; waitsFor -> done
|
|
21
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/string/foo.js', 'Blank'
|
|
22
|
-
sentry.watch __rootdir + '/spec/fixtures/string/foo.js', ->
|
|
23
|
-
expect(true).toBeTruthy()
|
|
24
|
-
done = true
|
|
25
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/string/foo.js', 'Hello World'
|
|
26
|
-
|
|
27
|
-
it 'runs a task when the file is changed', ->
|
|
28
|
-
done = false; waitsFor (-> done), null, 10000
|
|
29
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/string/bar.js', 'Blank'
|
|
30
|
-
sentry.watch __rootdir + '/spec/fixtures/string/bar.js', 'cake stub', (err, stdout, stderr) ->
|
|
31
|
-
expect(stdout.indexOf 'foo').toNotEqual -1
|
|
32
|
-
done = true
|
|
33
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/string/bar.js', 'Hello World'
|
|
34
|
-
|
|
35
|
-
it 'passes the filename to the callback' , ->
|
|
36
|
-
done = false; waitsFor -> done
|
|
37
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/string/baz.js', 'Blank'
|
|
38
|
-
sentry.watch __rootdir + '/spec/fixtures/string/baz.js', (filename) ->
|
|
39
|
-
expect(filename).toEqual __rootdir + '/spec/fixtures/string/baz.js'
|
|
40
|
-
done = true
|
|
41
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/string/baz.js', 'Hello World'
|
|
42
|
-
|
|
43
|
-
describe 'given a single wild card', ->
|
|
44
|
-
|
|
45
|
-
it 'runs a function when a file is changed', ->
|
|
46
|
-
done = false; waitsFor -> done
|
|
47
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/foo.js', 'Blank'
|
|
48
|
-
sentry.watch __rootdir + '/spec/fixtures/wildcard/*', ->
|
|
49
|
-
expect(true).toBeTruthy()
|
|
50
|
-
done = true
|
|
51
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/foo.js', 'Hello World'
|
|
52
|
-
|
|
53
|
-
it 'runs a task when a file is changed', ->
|
|
54
|
-
done = false; waitsFor (-> done), null, 10000
|
|
55
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/bar.js', 'Blank'
|
|
56
|
-
sentry.watch __rootdir + '/spec/fixtures/wildcard/*', 'cake stub', (err, stdout, stderr) ->
|
|
57
|
-
expect(stdout.indexOf 'foo').toNotEqual -1
|
|
58
|
-
done = true
|
|
59
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/bar.js', 'Hello World'
|
|
60
|
-
|
|
61
|
-
it 'it passes the filename to the callback', ->
|
|
62
|
-
done = false; waitsFor -> done
|
|
63
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/foo.js', 'Blank'
|
|
64
|
-
sentry.watch __rootdir + '/spec/fixtures/wildcard/*', (filename) ->
|
|
65
|
-
expect(filename.match(/foo|baz|qux|bar/)).toBeTruthy()
|
|
66
|
-
done = true
|
|
67
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/foo.js', 'Hello World'
|
|
68
|
-
|
|
69
|
-
it 'it only watches the file with given extension', ->
|
|
70
|
-
done = false; waitsFor -> done
|
|
71
|
-
filesWritten = 0
|
|
72
|
-
sentryWatchedFiles = 0
|
|
73
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/qux.js', 'Blank'
|
|
74
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/baz.coffee', 'Blank'
|
|
75
|
-
sentry.watch __rootdir + '/spec/fixtures/wildcard/*.coffee', (filename) ->
|
|
76
|
-
filesWritten++
|
|
77
|
-
sentryWatchedFiles++
|
|
78
|
-
if filesWritten is 2
|
|
79
|
-
expect(sentryWatchedFiles).toEqual 1
|
|
80
|
-
done = true
|
|
81
|
-
fs.watchFile __rootdir + '/spec/fixtures/wildcard/qux.js', (curr, prev) ->
|
|
82
|
-
filesWritten++
|
|
83
|
-
if filesWritten is 2
|
|
84
|
-
expect(sentryWatchedFiles).toEqual 1
|
|
85
|
-
done = true
|
|
86
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/qux.js', 'Hello World'
|
|
87
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/wildcard/baz.coffee', 'Hello World'
|
|
88
|
-
|
|
89
|
-
describe 'given a recursive wild card', ->
|
|
90
|
-
|
|
91
|
-
it 'runs a function when a deeply nested file is changed', ->
|
|
92
|
-
done = false; waitsFor -> done
|
|
93
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/foo.js', 'Blank'
|
|
94
|
-
sentry.watch __rootdir + '/spec/fixtures/deepwildcard/**/*.js', ->
|
|
95
|
-
expect(true).toBeTruthy()
|
|
96
|
-
done = true
|
|
97
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/foo.js', 'Hello World'
|
|
98
|
-
|
|
99
|
-
it 'runs a function when a not so deeply nested file is changed', ->
|
|
100
|
-
done = false; waitsFor (-> done), null, 10000
|
|
101
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/bar.js', 'Blank'
|
|
102
|
-
sentry.watch __rootdir + '/spec/fixtures/deepwildcard/**/*.js', 'cake stub', (err, stdout, stderr) ->
|
|
103
|
-
expect(stdout.indexOf 'foo').toNotEqual -1
|
|
104
|
-
done = true
|
|
105
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/bar.js', 'Hello World'
|
|
106
|
-
|
|
107
|
-
it 'it passes the filename to the callback', ->
|
|
108
|
-
done = false; waitsFor -> done
|
|
109
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/foo.js', 'Blank'
|
|
110
|
-
sentry.watch __rootdir + '/spec/fixtures/deepwildcard/**/*', (filename) ->
|
|
111
|
-
expect(filename.match(/foo|baz|qux/)).toBeTruthy()
|
|
112
|
-
done = true
|
|
113
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/foo.js', 'Hello World'
|
|
114
|
-
|
|
115
|
-
it 'it only watches the file with given extension', ->
|
|
116
|
-
done = false; waitsFor -> done
|
|
117
|
-
filesWritten = 0
|
|
118
|
-
sentryWatchedFiles = 0
|
|
119
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/qux.js', 'Blank'
|
|
120
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/baz.coffee', 'Blank'
|
|
121
|
-
sentry.watch __rootdir + '/spec/fixtures/deepwildcard/**/*.coffee', (filename) ->
|
|
122
|
-
filesWritten++
|
|
123
|
-
sentryWatchedFiles++
|
|
124
|
-
if filesWritten is 2
|
|
125
|
-
expect(sentryWatchedFiles).toEqual 1
|
|
126
|
-
done = true
|
|
127
|
-
fs.watchFile __rootdir + '/spec/fixtures/deepwildcard/deep/qux.js', (curr, prev) ->
|
|
128
|
-
filesWritten++
|
|
129
|
-
if filesWritten is 2
|
|
130
|
-
expect(sentryWatchedFiles).toEqual 1
|
|
131
|
-
done = true
|
|
132
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/qux.js', 'Hello World'
|
|
133
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/deepwildcard/deep/baz.coffee', 'Hello World'
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
describe 'sentry.watchRegExp', ->
|
|
137
|
-
|
|
138
|
-
it 'runs a function when a deeply nested file that matches the regex changes', ->
|
|
139
|
-
done = false; waitsFor -> done
|
|
140
|
-
fs.writeFileSync __rootdir + '/spec/fixtures/regex/deep/foo.txt', 'Blank'
|
|
141
|
-
sentry.watchRegExp './fixtures/regex/', /txt$/, ->
|
|
142
|
-
expect(true).toBeTruthy()
|
|
143
|
-
done = true
|
|
144
|
-
_.defer -> fs.writeFileSync __rootdir + '/spec/fixtures/regex/deep/foo.txt', 'Hello World'
|
|
145
|
-
|
|
146
|
-
describe 'sentry.findWildcards', ->
|
|
147
|
-
|
|
148
|
-
it 'given a /* type wildcard finds files one directory deep', ->
|
|
149
|
-
equal = _.isEqual sentry.findWildcards(__rootdir + '/spec/fixtures/wildcard/*'), [
|
|
150
|
-
'/Users/Craig/sentry/spec/fixtures/wildcard/bar.js',
|
|
151
|
-
'/Users/Craig/sentry/spec/fixtures/wildcard/baz.coffee',
|
|
152
|
-
'/Users/Craig/sentry/spec/fixtures/wildcard/foo.js',
|
|
153
|
-
'/Users/Craig/sentry/spec/fixtures/wildcard/qux.js'
|
|
154
|
-
]
|
|
155
|
-
expect(equal).toBeTruthy()
|
|
156
|
-
|
|
157
|
-
it 'given a /**/* type wildcard finds files recursive', ->
|
|
158
|
-
equal = _.isEqual sentry.findWildcards(__rootdir + '/spec/fixtures/deepwildcard/**/*'), [
|
|
159
|
-
'/Users/Craig/sentry/spec/fixtures/deepwildcard/bar.js',
|
|
160
|
-
'/Users/Craig/sentry/spec/fixtures/deepwildcard/deep/baz.coffee',
|
|
161
|
-
'/Users/Craig/sentry/spec/fixtures/deepwildcard/deep/foo.js',
|
|
162
|
-
'/Users/Craig/sentry/spec/fixtures/deepwildcard/deep/qux.js'
|
|
163
|
-
]
|
|
164
|
-
expect(equal).toBeTruthy()
|
|
165
|
-
|
|
166
|
-
it 'given a /**/*.coffee type wildcard finds files with only that extension', ->
|
|
167
|
-
equal = _.isEqual sentry.findWildcards(__rootdir + '/spec/fixtures/deepwildcard/**/*.coffee'), [
|
|
168
|
-
'/Users/Craig/sentry/spec/fixtures/deepwildcard/deep/baz.coffee'
|
|
169
|
-
]
|
|
170
|
-
expect(equal).toBeTruthy()
|
package/src/sentry.coffee
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Module dependencies
|
|
2
|
-
fileUtil = require 'file'
|
|
3
|
-
_ = require 'underscore'
|
|
4
|
-
fs = require 'fs'
|
|
5
|
-
exec = require('child_process').exec
|
|
6
|
-
path = require 'path'
|
|
7
|
-
|
|
8
|
-
# sentry.watch(file, [task], callback)
|
|
9
|
-
# If passed a task callback is passed (err, stdout, stderr)
|
|
10
|
-
# If task is ommitted then callback is passed (filename)
|
|
11
|
-
@watch = (file, task, callback) =>
|
|
12
|
-
|
|
13
|
-
callback = task if _.isFunction task
|
|
14
|
-
|
|
15
|
-
# If the file is a string without wildcards, watch just that file
|
|
16
|
-
if file.indexOf('/*') isnt -1
|
|
17
|
-
files = @findWildcards file
|
|
18
|
-
watchFile(file, task, callback) for file in files
|
|
19
|
-
|
|
20
|
-
# Get the files we want to catch with the wildcards
|
|
21
|
-
else
|
|
22
|
-
throw new Error("SENTRY: File '#{file}' does not exist!") unless path.existsSync file
|
|
23
|
-
watchFile(file, task, callback)
|
|
24
|
-
|
|
25
|
-
# sentry.watchRegExp(root, regex, [task], callback)
|
|
26
|
-
# If passed a task callback is passed (err, stdout, stderr)
|
|
27
|
-
# If task is ommitted then callback is passed (filename)
|
|
28
|
-
@watchRegExp = (root, regex, task, callback) ->
|
|
29
|
-
|
|
30
|
-
callback = task if _.isFunction task
|
|
31
|
-
|
|
32
|
-
# Recursively find anything that matches the regex
|
|
33
|
-
root = path.resolve(path.dirname(module.parent.filename), root)
|
|
34
|
-
files = []
|
|
35
|
-
fileUtil.walkSync root, (rt, flds, fls) ->
|
|
36
|
-
for fl in fls
|
|
37
|
-
flPath = rt + '/' + fl
|
|
38
|
-
files.push(flPath) if flPath.match regex
|
|
39
|
-
files
|
|
40
|
-
|
|
41
|
-
# Watch the matches files
|
|
42
|
-
watchFile(file, task, callback) for file in files
|
|
43
|
-
|
|
44
|
-
# Watch a file for changes and execute a callback or child process
|
|
45
|
-
watchFile = (file, task, callback) ->
|
|
46
|
-
fs.watchFile file, (curr, prev) ->
|
|
47
|
-
return if curr.size is prev.size and curr.mtime.getTime() is prev.mtime.getTime()
|
|
48
|
-
if _.isString task
|
|
49
|
-
exec 'cake stub', (err, stdout, stderr) ->
|
|
50
|
-
callback(err, stdout, stderr)
|
|
51
|
-
else
|
|
52
|
-
callback file
|
|
53
|
-
|
|
54
|
-
# Given a filename such as /fld/**/* return all recursive files
|
|
55
|
-
# or given a filename such as /fld/* return all files one directory deep.
|
|
56
|
-
# Limit by extension via /fld/**/*.coffee
|
|
57
|
-
@findWildcards = (file) ->
|
|
58
|
-
|
|
59
|
-
files = []
|
|
60
|
-
|
|
61
|
-
# If there is a wildcard in the /**/* form of a file then remove it and
|
|
62
|
-
# splice in all files recursively in that directory
|
|
63
|
-
if file? and file.indexOf('**/*') isnt -1
|
|
64
|
-
root = file.split('**/*')[0]
|
|
65
|
-
ext = file.split('**/*')[1]
|
|
66
|
-
fileUtil.walkSync root, (root, flds, fls) ->
|
|
67
|
-
root = (if root.charAt(root.length - 1) is '/' then root else root + '/')
|
|
68
|
-
for file in fls
|
|
69
|
-
if file.match(new RegExp ext + '$')? and _.indexOf(files, root + file) is -1
|
|
70
|
-
files.push(root + file)
|
|
71
|
-
|
|
72
|
-
# If there is a wildcard in the /* form then remove it and splice in all the
|
|
73
|
-
# files one directory deep
|
|
74
|
-
else if file? and file.indexOf('/*') isnt -1
|
|
75
|
-
root = file.split('/*')[0]
|
|
76
|
-
ext = file.split('/*')[1]
|
|
77
|
-
for file in fs.readdirSync(root)
|
|
78
|
-
if file.indexOf('.') isnt -1 and file.match(new RegExp ext + '$')? and _.indexOf(files, root + '/' + file) is -1
|
|
79
|
-
files.push(root + '/' + file)
|
|
80
|
-
|
|
81
|
-
files
|