Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Commit 1e6df3b

Browse files
committed
working !
1 parent c0b7aaf commit 1e6df3b

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

index.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
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
55
*/
66

77
const glob = require('glob');
@@ -22,10 +22,9 @@ module.exports = function(content){
2222
// So if the file is runned "inline", we need to change path into that path so that
2323
// __DIR__ point to the correct location.
2424
let cwd = this.context;
25+
26+
let query = ( typeof this.query === 'string' ? loaderUtils.parseQuery(this.query || '?') : this.query ) || {};
2527

26-
let query = loaderUtils.parseQuery(this.query || '?');
27-
28-
let callback = this.async();
2928
let options = Object.assign({
3029
proxyScript: null
3130
}, query);
@@ -44,23 +43,27 @@ module.exports = function(content){
4443
this.addDependency(resource);
4544
args.push(resource);
4645

47-
console.log('php '+shellescape(args));
46+
let callback = this.async();
47+
let value;
4848
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));
5051
//console.log('stdout:', stdout);
5152
//console.log('stderr:', stderr);
5253

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);
6162
}
6263

6364
}
6465
runPhp();
6566

6667
};
68+
69+
module.exports.raw = true;

0 commit comments

Comments
 (0)