Skip to content

Commit 82be855

Browse files
committed
Merge pull request #1299 from kamilkisiela/chore-dev-mode
chore: dev:start dev:stop to change -data package
2 parents 919c597 + 412003a commit 82be855

File tree

4 files changed

+50
-12
lines changed

4 files changed

+50
-12
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dist
33
docs
44
examples
55
packages
6+
scripts
67
src/lib
78
src/modules/angular-meteor-*.js
89
tests

.github/CONTRIBUTING.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,15 @@ cd myProject
131131
ln -s ~/path_to_your_repos/angular-meteor/packages/
132132
```
133133

134-
The `angular-meteor-data` package uses a node module.
134+
The `angular-meteor-data` package uses the main file of `angular-meteor` node module.
135135

136-
All you have to do is to change it in `package.js`:
136+
To start using a local file you should run:
137137

138-
```javascript
139-
api.add_files([
140-
// '.npm/package/node_modules/angular-meteor/dist/angular-meteor.js'
141-
'angular-meteor.js'
142-
], 'client', {
143-
transpile: false
144-
});
138+
```bash
139+
npm run dev:start
145140
```
146141

147-
As you can see, there is no `angular-meteor.js` file.
148-
149-
You can build this file by running:
142+
To compile new file for `angular-meteor-data` package you can run:
150143

151144
```bash
152145
npm run build:dev
@@ -158,8 +151,18 @@ If you don’t want to manually recompile after every change you can use watch m
158151
npm run watch:dev
159152
```
160153

154+
Both above commands run `npm run dev:start` automaticaly, so you don't have to trigger it by yourself.
155+
161156
Now you can start using your own copy of the `angular-meteor` project from `myProject`.
162157

158+
**You should remember one thing**.
159+
160+
Since `angular-meteor-data` package uses main file of `angular-meteor` npm package and you've already changed it using above commands, you should somehow restore that state. It's easy, just use this command:
161+
162+
```bash
163+
npm run dev:stop
164+
```
165+
163166
## Running tests
164167

165168
In the command line

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
"pretest": "npm run build:dist",
1919
"test": "velocity test-packages ./tests --ci",
2020
"test:watch": "parallelshell \"npm run watch\" \"velocity test-packages ./tests\"",
21+
"dev:start": "node scripts/dev.js",
22+
"dev:stop": "node scripts/dev.js --stop",
2123
"watch": "webpack --watch --progress --config webpack/dist.js",
24+
"prewatch:dev": "npm run dev:start",
2225
"watch:dev": "webpack --watch --progress --config webpack/dev.js",
2326
"build:dist": "webpack --progress --config webpack/dist.js",
27+
"prebuild:dev": "npm run dev:start",
2428
"build:dev": "webpack --progress --config webpack/dev.js",
2529
"build:prod": "webpack --progress --config webpack/prod.js --optimize-minimize",
2630
"build": "npm run build:dist && npm run build:prod",
@@ -55,6 +59,7 @@
5559
"husky": "^0.11.1",
5660
"lodash": "^3.10.1",
5761
"parallelshell": "^2.0.0",
62+
"replace-in-file": "^1.0.2",
5863
"validate-commit-msg": "^2.0.0",
5964
"velocity-cli": "^0.4.3",
6065
"webpack": "^1.12.9"

scripts/dev.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env node
2+
var replace = require('replace-in-file');
3+
var fs = require('fs');
4+
var isStop = process.argv.slice(2).indexOf('--stop') !== -1;
5+
6+
// path to angular-meteor-data package
7+
var path = 'packages/angular-meteor-data/';
8+
// package definition
9+
var packageFile = path + 'package.js';
10+
// angular-meteor file
11+
var npmFile = '.npm/package/node_modules/angular-meteor/dist/angular-meteor.js';
12+
var devFile = 'angular-meteor.js';
13+
14+
// replace options
15+
var options = {
16+
files: packageFile,
17+
replace: isStop ? devFile : npmFile,
18+
with: isStop ? npmFile : devFile
19+
};
20+
21+
// clean up first
22+
try {
23+
if (fs.accessSync(path + devFile, fs.F_OK)) {
24+
fs.unlinkSync(path + devFile);
25+
}
26+
} catch(e) {}
27+
28+
// make sure package uses proper file
29+
replace(options);

0 commit comments

Comments
 (0)