-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.js
72 lines (52 loc) · 1.19 KB
/
package.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Package.describe({
name: 'scw:add2package',
version: '0.0.1',
summary: 'Easily add files and assets to your packages - with Globs!',
git: 'https://github.com/sircharleswatson/add2package',
documentation: 'README.md'
})
Package.onUse(function(api) {
api.versionsFrom('1.2.0.1')
})
/*
*
* Add2Package
*
*/
var path = Npm.require('path');
var Glob = Npm.require('glob');
var packageFolderName = '';
var packageApi;
addFiles = function(glob, target) {
dirExists();
target = parseTarget(target);
var files = getFiles(glob);
packageApi.addFiles(files, target);
}
addAssets = function(glob, target) {
dirExists();
target = parseTarget(target);
}
packageFolder = function(name, api) {
packageFolderName = name;
packageApi = api;
}
function dirExists() {
if (packageFolderName == '') {
throw new Error();
}
}
function getFiles(glob) {
var options = {};
options.cwd = path.join(process.cwd(), '/packages/', packageFolderName);
var globResults = Glob.sync(glob, options);
return globResults;
}
function parseTarget(target) {
if (target === "both" || target === undefined) {
target = ['client', 'server'];
} else {
target = [target];
}
return target;
}