Skip to content

Commit

Permalink
Also catch lines which begin with whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mallorydxw committed Jan 6, 2016
1 parent 9101da4 commit 50dff14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/modules/helpers/manifest_io.trait.php
Expand Up @@ -12,7 +12,7 @@ protected function load_plugins_manifest() {
$raw_file = file_get_contents($this->plugins_manifest_file);
$lines = explode("\n", $raw_file);
foreach ($lines as $line) {
if (preg_match('/^#/', $line)) {
if (preg_match('/^\s*#/', $line)) {
echo "Comments beginning with # are not permitted\n";
exit(1);
}
Expand Down Expand Up @@ -141,4 +141,4 @@ private function update_plugins_lock()

return file_put_contents($this->plugins_lock_file, json_encode($this->plugins_locked, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
};
};
16 changes: 16 additions & 0 deletions tests/plugins_test.php
Expand Up @@ -71,4 +71,20 @@ function testDeprecatedCommentSyntax()
$this->assertNotContains('PHP Notice', $stderr);
$this->assertNotContains('PHP Deprecated', $stderr);
}

function testDeprecatedCommentSyntax2()
{
// Add whitespace before the #
$this->createTestDir();
file_put_contents($this->dir.'/plugins', "source = \"git-repo/\"\nadvanced-custom-fields=\n # a bad comment\n");

list($return, $stdout, $stderr) = $this->cmd('../../bin/whippet plugins install', dirname(__DIR__).'/'.$this->dir);

$this->assertEquals(1, $return);

$this->assertNotContains('PHP Fatal error', $stderr);
$this->assertNotContains('PHP Warning', $stderr);
$this->assertNotContains('PHP Notice', $stderr);
$this->assertNotContains('PHP Deprecated', $stderr);
}
}

0 comments on commit 50dff14

Please sign in to comment.