Build the package
$ cd ~/docs/tmp
$ meteor create --package leechau:segmentation
$ cd segmentation
$ cat << EOF > segmentation.js
Seg = 'segment results in Chinese';
Seg2 = function(inp){
return inp.toUpperCase();
}
EOF
$ cat << EOF > package.js
Package.describe({
name: 'leechau:segmentation',
version: '0.0.1',
// Brief, one-line summary of the package.
summary: 'for chinese segmentation',
// URL to the Git repository containing the source code for this package.
git: 'https://github.com/leetschau/meteorSegmentation',
// By default, Meteor will default to using README.md for documentation.
// To avoid submitting documentation, set this field to null.
documentation: 'README.md'
});
Package.onUse(function(api) {
api.versionsFrom('1.1.0.2');
api.addFiles('segmentation.js', 'client');
api.export(['Seg', 'Seg2'], 'client');
});
Package.onTest(function(api) {
api.use('tinytest');
api.use('leechau:segmentation');
api.addFiles('segmentation-tests.js');
});
EOF
$ cd ~/docs/tmp
$ meteor create testpkg
$ cd testpkg
$ mkdir packages
$ ln -s ~/docs/tmp/segmentation packages/segmentation
Add the following lines into 'click button' of testpkg.js file:
console.log(Seg);
console.log(Seg2('axd'));
Note:
-
api.export
is necessary inPackage.onUse
function of package.js file. -
The soft link does not contains the username part, to compare with atmospherejs.com publishing doc. So the package you created is "leechau:segmentation" in
meteor create --package
. While the soft link is "segmentation", not "leechau:segmentation".