Skip to content

Commit b0f379e

Browse files
authored
Merge pull request #28 from marinaglancy/gruntmap
Grunt should also check .js.map files
2 parents ac54892 + b261a41 commit b0f379e

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
1212
### Changed
1313
- Updated [.travis.dist.yml] to use Postgresql 9.6 (Moodle 3.10 new requirement).
1414

15+
### Fixed
16+
- `moodle-plugin-ci grunt` now also checks `*.js.map` files.
17+
1518
## [3.0.0] - 2020-07-23
1619
### Changed
1720
- ACTION REQUIRED: project organization renamed to moodlehq. You must update your `.travis.yml` to use `moodlehq/moodle-plugin-ci`

src/Command/GruntCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function validatePluginFiles(OutputInterface $output)
132132
$code = 0;
133133

134134
// Look for modified files or files that should be deleted.
135-
$files = Finder::create()->files()->in($this->backupDir)->name('*.js')->name('*.css')->getIterator();
135+
$files = Finder::create()->files()->in($this->backupDir)->name('*.js')->name('*.js.map')->name('*.css')->getIterator();
136136
foreach ($files as $file) {
137137
$compareFile = $this->plugin->directory.'/'.$file->getRelativePathname();
138138
if (!file_exists($compareFile)) {
@@ -148,7 +148,7 @@ public function validatePluginFiles(OutputInterface $output)
148148
}
149149

150150
// Look for newly generated files.
151-
$files = Finder::create()->files()->in($this->plugin->directory)->name('*.js')->name('*.css')->getIterator();
151+
$files = Finder::create()->files()->in($this->plugin->directory)->name('*.js')->name('*.js.map')->name('*.css')->getIterator();
152152
foreach ($files as $file) {
153153
if (!file_exists($this->backupDir.'/'.$file->getRelativePathname())) {
154154
$output->writeln(sprintf('<error>File is newly generated and needs to be added: %s</error>', $file->getRelativePathname()));

tests/Command/GruntCommandTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,25 @@ public function testValidatePluginFiles()
193193
$output = new BufferedOutput();
194194
$this->assertSame(1, $command->validatePluginFiles($output));
195195
$this->assertSame("File is newly generated and needs to be added: amd/build/new.min.js\n", $output->fetch());
196+
197+
$command->restorePlugin();
198+
$this->assertSame(0, $command->validatePluginFiles($emptyOutput));
199+
$this->assertSame('', $emptyOutput->fetch());
200+
201+
$this->fs->remove($this->pluginDir.'/amd/build/keys.min.js.map');
202+
203+
$output = new BufferedOutput();
204+
$this->assertSame(1, $command->validatePluginFiles($output));
205+
$this->assertSame("File no longer generated and likely should be deleted: amd/build/keys.min.js.map\n", $output->fetch());
206+
207+
$command->restorePlugin();
208+
$this->assertSame(0, $command->validatePluginFiles($emptyOutput));
209+
$this->assertSame('', $emptyOutput->fetch());
210+
211+
$this->fs->touch($this->pluginDir.'/amd/build/new.min.js.map');
212+
213+
$output = new BufferedOutput();
214+
$this->assertSame(1, $command->validatePluginFiles($output));
215+
$this->assertSame("File is newly generated and needs to be added: amd/build/new.min.js.map\n", $output->fetch());
196216
}
197217
}

0 commit comments

Comments
 (0)