Asaf
Asaf

Reputation: 8206

Adding files to bundle on meteor build

I have a meteor project, and I'd like to add a few bash scripts to the top directory in the bundle.tgz

I'm currently creating my bundle via:
meteor build bundle.tgz

Is there a way to configure the build so that it would include those bash scripts on the top of the resulted tgz file?

Upvotes: 2

Views: 866

Answers (1)

Tarang
Tarang

Reputation: 75945

Create a bundling script

Create a file in the root directory of your project, create_bundle.sh, also add in your other scripts to the root directory of your project. I've used the example of one file, some_file.sh, add any more as you need

create_bundle.sh

#!/bin/sh
rm -f bundle.tar.gz
rm -rf /tmp/bundle
meteor build /tmp/bundle
tar -xzf /tmp/bundle/*.tar.gz -C /tmp/bundle

## Add any more as needed
cp some_file.sh /tmp/bundle/bundle

rm /tmp/bundle/*.tar.gz
tar -cvzf bundle.tar.gz -C /tmp/bundle .

Now if you run ./create_bundle.sh instead of meteor build bundle.tar.gz it will:

  • Create a bundle.tar.gz in your project directory
  • The bundle.tar.gz will have some_file.sh added to it too in the bundle folder. You can move this to the root folder by altering the cp line in the create_bundle.sh to use /tmp/bundle/ instead of /tmp/bundle/bundle

Alternative Modify the Meteor source

One option would be to git clone the meteor source

git clone http://github.com/meteor/meteor

Edit the file meteor/tools/bundler.js (at this point: https://github.com/meteor/meteor/blob/f59380a6cfb1d09a6d8ef9abda11646d37e37356/tools/bundler.js#L1910)

and add in your batch file

builder.write('yourfile.sh', { data: new Buffer(
    "#!/bin/sh
    "echo 'hello world'\n", 'utf8')});
});

You can then build your project with this special build of meteor:

From your project directory (*nix):

/path/to/cloned_meteor_repo/meteor build yourfile.tar.gz

Upvotes: 3

Related Questions