Skip to content

Commit

Permalink
fixing some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
reisraff committed Jan 30, 2018
1 parent 43bc777 commit fe71ab3
Show file tree
Hide file tree
Showing 8 changed files with 392 additions and 241 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vendor
!/bin/phulp
.tmp
src/bower_components/
example/dist
50 changes: 34 additions & 16 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,39 @@ the ones matching the following pattern `[P,p]hulp[Ff]il{e,e.php}` nevertheless

```php
<?php

// Define the default task
$phulp->task('default', function ($phulp) {
$phulp->start(['clean', 'iterate_src_folder', 'sync_command', 'assync_command']);
});

// Define the clean task
$phulp->task('clean', function ($phulp) {
if (! file_exists('dist')) {
mkdir('dist');
}
$phulp->src(['dist/'])
->pipe($phulp->clean());
});

// Define the iterate_src_folder task
$phulp->task('iterate_src_folder', function ($phulp) {
// Define the source folder
$phulp->src(['src/'], '/php$/', false)
->pipe($phulp->iterate(function ($distFile) {
\Phulp\Output::out(
\Phulp\Output::colorize('File Changed ->', 'green')
. ' ' . \Phulp\Output::colorize(
$distFile->getFullPath() . DIRECTORY_SEPARATOR . $distFile->getName(),
'blue'
)
);
}))
->pipe($phulp->dest('dist/'));
});

// Define the sync_command task
$phulp->task('sync_command', function ($phulp) {
$return = $phulp->exec(
[
'command' => 'echo $MSG',
Expand All @@ -22,7 +52,10 @@ $phulp->task('default', function ($phulp) {

// $return['exit_code']
// $return['output']
});

// Define the assync_command task
$phulp->task('assync_command', function ($phulp) {
$phulp->exec(
[
'command' => 'echo $MSG',
Expand All @@ -36,21 +69,6 @@ $phulp->task('default', function ($phulp) {
// do something
}
);

$phulp->start(['clean']);

// Define the source folder
$phulp->src(['src/'], '/php$/', false)
->pipe($phulp->iterate(function ($distFile) {
\Phulp\Output::out(\Phulp\Output::colorize($distFile->getName(), 'blue'));
}))
->pipe($phulp->dest('dist/'));
});

// Define the clean task
$phulp->task('clean', function ($phulp) {
$phulp->src(['dist/'])
->pipe($phulp->clean());
});

// Define the watch task
Expand Down
63 changes: 47 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Total Downloads](https://poser.pugx.org/reisraff/phulp/downloads)](https://packagist.org/packages/reisraff/phulp)
[![Latest Unstable Version](https://poser.pugx.org/reisraff/phulp/v/unstable)](https://packagist.org/packages/reisraff/phulp)
[![License](https://poser.pugx.org/reisraff/phulp/license)](https://packagist.org/packages/reisraff/phulp)
[![Build Status](https://travis-ci.org/reisraff/phulp.svg?branch=master)](https://travis-ci.org/reisraff/phulp)
[![Build Status](https://api.travis-ci.org/reisraff/phulp.svg?branch=master)](https://travis-ci.org/reisraff/phulp)

### Why

Expand All @@ -33,6 +33,36 @@ $ composer require --dev reisraff/phulp

// Define the default task
$phulp->task('default', function ($phulp) {
$phulp->start(['clean', 'iterate_src_folder', 'sync_command', 'assync_command']);
});

// Define the clean task
$phulp->task('clean', function ($phulp) {
if (! file_exists('dist')) {
mkdir('dist');
}
$phulp->src(['dist/'])
->pipe($phulp->clean());
});

// Define the iterate_src_folder task
$phulp->task('iterate_src_folder', function ($phulp) {
// Define the source folder
$phulp->src(['src/'], '/php$/', false)
->pipe($phulp->iterate(function ($distFile) {
\Phulp\Output::out(
\Phulp\Output::colorize('File Changed ->', 'green')
. ' ' . \Phulp\Output::colorize(
$distFile->getFullPath() . DIRECTORY_SEPARATOR . $distFile->getName(),
'blue'
)
);
}))
->pipe($phulp->dest('dist/'));
});

// Define the sync_command task
$phulp->task('sync_command', function ($phulp) {
$return = $phulp->exec(
[
'command' => 'echo $MSG',
Expand All @@ -45,7 +75,10 @@ $phulp->task('default', function ($phulp) {

// $return['exit_code']
// $return['output']
});

// Define the assync_command task
$phulp->task('assync_command', function ($phulp) {
$phulp->exec(
[
'command' => 'echo $MSG',
Expand All @@ -59,21 +92,6 @@ $phulp->task('default', function ($phulp) {
// do something
}
);

$phulp->start(['clean']);

// Define the source folder
$phulp->src(['src/'], '/php$/', false)
->pipe($phulp->iterate(function ($distFile) {
\Phulp\Output::out(\Phulp\Output::colorize($distFile->getName(), 'blue'));
}))
->pipe($phulp->dest('dist/'));
});

// Define the clean task
$phulp->task('clean', function ($phulp) {
$phulp->src(['dist/'])
->pipe($phulp->clean());
});

// Define the watch task
Expand Down Expand Up @@ -102,6 +120,19 @@ $ vendor/bin/phulp watch # Will run the `watch` task

[Docs](https://github.com/reisraff/phulp/blob/master/DOCUMENTATION.md)

##### Example:

[https://github.com/reisraff/phulp/blob/master/example/phulpfile.php](https://github.com/reisraff/phulp/blob/master/example/phulpfile.php)

Run the example file:

```bash
$ composer install
$ cd example
$ ../bin/phulp
$ ../bin/phulp watch
```

### Contributors Guide

#### Clone
Expand Down
15 changes: 8 additions & 7 deletions bin/phulp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

$version = '1.9.1';

foreach (['../../../autoload.php', '../../autoload.php', '../vendor/autoload.php', 'vendor/autoload.php'] as $autoload) {
$autoload = __DIR__.'/'.$autoload;
$files = ['../../../autoload.php', '../../autoload.php', '../vendor/autoload.php', 'vendor/autoload.php'];
foreach ($files as $autoload) {
$autoload = __DIR__ . '/' . $autoload;
if (file_exists($autoload)) {
require $autoload;
break;
Expand All @@ -12,7 +13,7 @@

ini_set('register_argc_argv', true);

if (count($argv > 1)) {
if (count($argv) > 1) {
foreach ($argv as $key => $value) {
if ($value == '-q' || $value == '--quiet') {
Phulp\Output::$quiet = true;
Expand Down Expand Up @@ -40,16 +41,16 @@
/_/ /_/ /_/\__,_/_/ .___/
/_/ ' . PHP_EOL
. Phulp\Output::colorize('Phulp', 'green')
. ' version ' . Phulp\Output::colorize($version, 'yellow') . PHP_EOL . PHP_EOL
. ' version ' . Phulp\Output::colorize($version, 'yellow') . PHP_EOL . PHP_EOL
. Phulp\Output::colorize('Usage:', 'yellow') . PHP_EOL
. ' [task = default] [options]' . PHP_EOL . PHP_EOL
. Phulp\Output::colorize('Options:', 'yellow') . PHP_EOL
. Phulp\Output::colorize(' -h, --help', 'green')
. ' Display this help message' . PHP_EOL
. ' Display this help message' . PHP_EOL
. Phulp\Output::colorize(' -q, --quiet', 'green')
. ' Do not output any message' . PHP_EOL
. ' Do not output any message' . PHP_EOL
. Phulp\Output::colorize(' -V, --version', 'green')
. ' Display this application version' . PHP_EOL
. ' Display this application version' . PHP_EOL
);
exit(0);
}
Expand Down
1 change: 1 addition & 0 deletions build.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<target name="phpcs" description="Coding Standards Analysis">
<exec passthru="true" command="${bindir}/phpcs --standard=PSR2 ${source}" checkreturn="true" />
<exec passthru="true" command="${bindir}/phpcs --standard=PSR2 ${bindir}/phulp.php" checkreturn="true" />
<exec passthru="true" command="${bindir}/phpcs --standard=PSR2 ${test}" checkreturn="true" />
</target>
</project>
Loading

0 comments on commit fe71ab3

Please sign in to comment.