Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 5ac865e

Browse files
ficristoficristo
authored andcommitted
Create config.json based on task run
1 parent 300f3d0 commit 5ac865e

6 files changed

Lines changed: 27 additions & 6 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Thumbs.db
2323
# ignore .disabled file for default extensions
2424
/src/extensions/default/*/.disabled
2525

26+
# generate through grunt
27+
/src/config.json
28+
2629
#OSX .DS_Store files
2730
.DS_Store
2831

Gruntfile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,19 @@ module.exports = function (grunt) {
323323
});
324324

325325
// task: install
326-
grunt.registerTask('install', ['write-config', 'less', 'npm-install-extensions']);
326+
grunt.registerTask('install', ['write-config:dev', 'less', 'npm-install-extensions']);
327327

328328
// task: test
329329
grunt.registerTask('test', ['eslint', 'jasmine', 'nls-check']);
330330
// grunt.registerTask('test', ['eslint', 'jasmine', 'jasmine_node', 'nls-check']);
331331

332332
// task: set-release
333333
// Update version number in package.json and rewrite src/config.json
334-
grunt.registerTask('set-release', ['update-release-number', 'write-config']);
334+
grunt.registerTask('set-release', ['update-release-number', 'write-config:dev']);
335335

336336
// task: build
337337
grunt.registerTask('build', [
338+
'write-config:dist',
338339
'eslint:src',
339340
'jasmine',
340341
'clean',

src/brackets.config.dev.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"healthDataServerURL" : "https://healthdev.brackets.io/healthDataLog"
3+
}

src/brackets.config.dist.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"healthDataServerURL" : "https://health.brackets.io/healthDataLog"
3+
}

src/brackets.config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"extension_registry" : "https://s3.amazonaws.com/extend.brackets/registry.json",
2121
"extension_url" : "https://s3.amazonaws.com/extend.brackets/{0}/{0}-{1}.zip",
2222
"linting.enabled_by_default" : true,
23-
"build_timestamp" : "",
24-
"healthDataServerURL" : "https://health.brackets.io/healthDataLog"
23+
"build_timestamp" : ""
2524
}
2625
}

tasks/write-config.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,21 @@ module.exports = function (grunt) {
3131

3232
// task: write-config
3333
grunt.registerTask("write-config", "Merge package.json and src/brackets.config.json into src/config.json", function () {
34-
var packageJSON = grunt.file.readJSON("package.json"),
35-
appConfigJSON = grunt.file.readJSON("src/brackets.config.json");
34+
var name = "dev";
35+
if (this.flags.dist === true) {
36+
name = "dist";
37+
}
3638

39+
var appConfigJSON = grunt.file.readJSON("src/brackets.config.json"),
40+
appConfigEnvJSON = grunt.file.readJSON("src/brackets.config." + name + ".json"),
41+
key;
42+
for (key in appConfigEnvJSON) {
43+
if (appConfigEnvJSON.hasOwnProperty(key)) {
44+
appConfigJSON.config[key] = appConfigEnvJSON[key];
45+
}
46+
}
47+
48+
var packageJSON = grunt.file.readJSON("package.json");
3749
Object.keys(packageJSON).forEach(function (key) {
3850
if (appConfigJSON[key] === undefined) {
3951
appConfigJSON[key] = packageJSON[key];

0 commit comments

Comments
 (0)