Created
May 30, 2014 15:03
-
-
Save kevinoconnor7/9793d4bc29747139ffee to your computer and use it in GitHub Desktop.
Arcanist - strip json comments patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From be0511f947e256b8d6b16360369945eefdaf1073 Mon Sep 17 00:00:00 2001 | |
From: Kevin O'Connor <[email protected]> | |
Date: Fri, 30 May 2014 11:03:01 -0400 | |
Subject: [PATCH] Strip json comments before json_decode | |
--- | |
src/lint/engine/ArcanistConfigurationDrivenLintEngine.php | 3 ++- | |
src/workingcopyidentity/ArcanistWorkingCopyIdentity.php | 2 +- | |
2 files changed, 3 insertions(+), 2 deletions(-) | |
diff --git a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php | |
index 709909e..98a63fe 100644 | |
--- a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php | |
+++ b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php | |
@@ -13,11 +13,12 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { | |
} | |
$data = Filesystem::readFile($config_path); | |
+ $data = preg_replace("/\s+\/\/.*\n/mi","\n",$data); | |
$config = json_decode($data, true); | |
if (!is_array($config)) { | |
throw new Exception( | |
"Expected '.arclint' file to be a valid JSON file, but failed to ". | |
- "decode it: {$config_path}"); | |
+ "decode it: {$config_path}\n\n File: {$data}"); | |
} | |
$linters = $this->loadAvailableLinters(); | |
diff --git a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php | |
index 7fe15ed..3c748a3 100644 | |
--- a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php | |
+++ b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php | |
@@ -201,7 +201,7 @@ final class ArcanistWorkingCopyIdentity { | |
} | |
private static function parseRawConfigFile($raw_config, $from_where) { | |
- $proj = json_decode($raw_config, true); | |
+ $proj = json_decode(preg_replace("/\s+\/\/.*\n/mi","\n",$raw_config), true); | |
if (!is_array($proj)) { | |
throw new Exception( | |
-- | |
2.0.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment