-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Recca Tsai
committed
Apr 5, 2016
1 parent
5330ef5
commit d068586
Showing
9 changed files
with
137 additions
and
27 deletions.
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'user strict'; | ||
|
||
let $; | ||
if (!window.jQuery) { | ||
$ = window.jQuery = window.$ = require('jquery'); | ||
} else { | ||
$ = window.jQuery; | ||
} | ||
|
||
export default $; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
import $ from 'jquery'; | ||
import $ from './jquery'; | ||
|
||
if (!Object.assign) { | ||
Object.assign = $.extend; | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Recca0120\Terminal\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Filesystem\Filesystem; | ||
|
||
class Tail extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'tail | ||
{path?} | ||
{--lines=50 : output the last K lines, instead of the last 50} | ||
'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'tail command'; | ||
|
||
/** | ||
* handle. | ||
* | ||
* @param \Illuminate\Filesystem\Filesystem $filesystem | ||
* | ||
* @return void | ||
*/ | ||
public function handle(Filesystem $filesystem) | ||
{ | ||
$path = $this->argument('path'); | ||
$lines = $this->option('lines'); | ||
|
||
if (empty($path) === false) { | ||
$path = ((is_null($this->laravel) === false) ? $this->laravel->basePath() : getcwd()).'/'.$path; | ||
} else { | ||
$path = (is_null($this->laravel) === false) ? $this->laravel->storagePath() : getcwd(); | ||
$path = collect($filesystem->glob($path.'/logs/*.log')) | ||
->filter(function ($log) { | ||
return is_file($log); | ||
}) | ||
->sortByDesc(function ($log) { | ||
return filectime($log); | ||
}) | ||
->first(); | ||
} | ||
|
||
$this->readLine($path, $lines); | ||
} | ||
|
||
protected function readLine($file, $lines = 50) | ||
{ | ||
if (file_exists($file) === false) { | ||
return 'tail: cannot open ‘'.$file.'’ for reading: No such file or directory'; | ||
} | ||
|
||
$fp = fopen($file, 'r'); | ||
$i = 1; | ||
$result = []; | ||
while (!feof($fp)) { | ||
if ($i > $lines) { | ||
break; | ||
} | ||
$content = fgets($fp); | ||
$result[] = $content; | ||
$i++; | ||
} | ||
fclose($fp); | ||
|
||
$this->line(implode('', $result)); | ||
} | ||
} |
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