forked from meteorhacks/npm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.js
40 lines (33 loc) · 1.08 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
var path = Npm.require('path');
var fs = Npm.require('fs');
var packagesJsonFile = path.resolve('./packages.json');
//creating `packages.json` file for the first-time if not exists
if(!fs.existsSync(packagesJsonFile)) {
fs.writeFileSync(packagesJsonFile, '{\n \n}')
}
try {
var fileContent = fs.readFileSync(packagesJsonFile);
var packages = JSON.parse(fileContent.toString());
Npm.depends(packages);
} catch(ex) {
console.error('ERROR: packages.json parsing error [ ' + ex.message + ' ]');
}
Package.describe({
summary: "complete npm integration/support for Meteor"
});
Package.on_use(function (api, where) {
api.export('Async');
var packagesFile = './.meteor/packages';
if(fs.existsSync(packagesFile) && isNewerMeteor) {
api.add_files(['index.js', '../../packages.json'], 'server');
} else {
api.add_files(['index.js'], 'server');
}
function isNewerMeteor() {
return fs.readFileSync(packagesFile, 'utf8').match(/\nstandard-app-packages/);
}
});
Package.on_test(function (api) {
api.use(['tinytest']);
api.add_files(['index.js', 'test.js'], 'server');
});