Skip to content

Commit

Permalink
#24 Append sass compiled to gitignore.
Browse files Browse the repository at this point in the history
  • Loading branch information
amostajo committed Jan 14, 2020
1 parent 68e17c3 commit d175b1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Traits/CreateAssetTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ protected function createAsset($type, $filename, $args = null)
$this->_print($ispart ? 'Asset exists!' : 'Master asset exists!');
$this->_lineBreak();
}
// Add compiled file to .gitignore
$gitignore = $this->rootPath.'/.gitignore';
$master = $ispart ? $args['importin'] : $filename;
$contents = is_file($gitignore) ? file_get_contents($gitignore) : '';
if (strpos($contents, '/assets/raw/css/'.$master) === false) {
$contents .= "\n".'# SASS COMPILATION'."\n".'/assets/raw/css/'.$master.'.css';
file_put_contents($gitignore, $contents);
}
break;
}
} catch (Exception $e) {
Expand Down
15 changes: 14 additions & 1 deletion tests/cases/CreateAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,21 @@ public function testSassMasterAndParts()
$this->assertFileExists($masterfile);
$this->assertFileExists($part1file);
$this->assertFileExists($part2file);
$this->assertPregMatchContents('/master/', $masterfile);
$this->assertPregMatchContents('/\@import(|\s)\\\'parts\/header\\\'\;/', $masterfile);
$this->assertPregMatchContents('/\@import(|\s)\\\'parts\/footer\\\'\;/', $masterfile);
}
/**
* Test.
*/
public function testSassGitignore()
{
// Prepare
$filename = FRAMEWORK_PATH.'/environment/.gitignore';
// Execure
exec('php '.WPMVC_AYUCO.' create sass:theme');
// Assert
$this->assertFileExists($filename);
$this->assertPregMatchContents('/\# SASS COMPILATION/', $filename);
unlink($filename);
}
}

0 comments on commit d175b1b

Please sign in to comment.