1
1
/*
2
2
MIT License http://www.opensource.org/licenses/mit-license.php
3
3
Author Jo <jo@redcat.ninja> https://github.com/surikat/
4
- based on https://www.npmjs.com/package/php-loader by Tobias Koppers @sokra
4
+ inspired by https://www.npmjs.com/package/php-loader by Tobias Koppers @sokra
5
5
*/
6
6
7
7
const glob = require ( 'glob' ) ;
@@ -22,10 +22,9 @@ module.exports = function(content){
22
22
// So if the file is runned "inline", we need to change path into that path so that
23
23
// __DIR__ point to the correct location.
24
24
let cwd = this . context ;
25
+
26
+ let query = ( typeof this . query === 'string' ? loaderUtils . parseQuery ( this . query || '?' ) : this . query ) || { } ;
25
27
26
- let query = loaderUtils . parseQuery ( this . query || '?' ) ;
27
-
28
- let callback = this . async ( ) ;
29
28
let options = Object . assign ( {
30
29
proxyScript : null
31
30
} , query ) ;
@@ -44,23 +43,27 @@ module.exports = function(content){
44
43
this . addDependency ( resource ) ;
45
44
args . push ( resource ) ;
46
45
47
- console . log ( 'php ' + shellescape ( args ) ) ;
46
+ let callback = this . async ( ) ;
47
+ let value ;
48
48
async function runPhp ( ) {
49
- const { stdout, stderr} = await exec ( 'php ' + shellescape ( args ) ) ;
49
+ //console.log('php '+shellescape(args));
50
+ let { stdout, stderr} = await exec ( 'php ' + shellescape ( args ) ) ;
50
51
//console.log('stdout:', stdout);
51
52
//console.log('stderr:', stderr);
52
53
53
- if ( stdout && stderr ) {
54
- if ( stderr ) {
55
- self . emitError ( stderr ) ;
56
- callback ( stderr ) ;
57
- }
58
- else {
59
- callback ( null , stdout ) ;
60
- }
54
+ stdout = 'module.exports = `' + stdout + '`;' ;
55
+
56
+ if ( stderr ) {
57
+ self . emitError ( stderr ) ;
58
+ callback ( stderr ) ;
59
+ }
60
+ else {
61
+ callback ( null , stdout ) ;
61
62
}
62
63
63
64
}
64
65
runPhp ( ) ;
65
66
66
67
} ;
68
+
69
+ module . exports . raw = true ;
0 commit comments