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

Commit 36f45c3

Browse files
ficristoficristo
authored andcommitted
Create config.json based on task run
1 parent 74c5306 commit 36f45c3

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
@@ -30,6 +30,9 @@ Thumbs.db
3030
# ignore .disabled file for default extensions
3131
/src/extensions/default/*/.disabled
3232

33+
# generate through grunt
34+
/src/config.json
35+
3336
#OSX .DS_Store files
3437
.DS_Store
3538

Gruntfile.js

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

343343
// task: install
344-
grunt.registerTask('install', ['write-config', 'less', 'npm-install-source']);
344+
grunt.registerTask('install', ['write-config:dev', 'less', 'npm-install-source']);
345345

346346
// task: test
347347
grunt.registerTask('test', ['eslint', 'jasmine', 'nls-check']);
348348
// grunt.registerTask('test', ['eslint', 'jasmine', 'jasmine_node', 'nls-check']);
349349

350350
// task: set-release
351351
// Update version number in package.json and rewrite src/config.json
352-
grunt.registerTask('set-release', ['update-release-number', 'write-config']);
352+
grunt.registerTask('set-release', ['update-release-number', 'write-config:dev']);
353353

354354
// task: build
355355
grunt.registerTask('build', [
356+
'write-config:dist',
356357
'eslint:src',
357358
'jasmine',
358359
'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)