-
Notifications
You must be signed in to change notification settings - Fork 15
/
php.js
31 lines (25 loc) · 1.1 KB
/
php.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const path = require('path');
const fs = require('fs');
const _ = require('lodash');
const phpLoader = require('./php-loader');
const loaderUtils = require('loader-utils');
module.exports = function (indexContent) {
let options = {};
let baseDirectory;
let loaderPath = 'node_modules' + path.sep + '@kirschbaum-development' + path.sep + 'laravel-translations-loader' + path.sep + 'php.js';
try {
options = loaderUtils.getOptions(this);
} catch (e) { }
if (path.dirname(this.resource).includes(path.dirname(loaderPath))) {
baseDirectory = path.dirname(this.resource) + path.sep + '..' + path.sep + '..' + path.sep + '..' + path.sep + 'lang';
if (! fs.existsSync(baseDirectory)) {
baseDirectory = path.dirname(this.resource) + path.sep + '..' + path.sep + '..' + path.sep + '..' + path.sep + 'resources' + path.sep + 'lang';
}
} else {
baseDirectory = path.dirname(this.resource);
}
this.addDependency(baseDirectory);
return "module.exports = " + JSON.stringify(
phpLoader.execute(baseDirectory, options, this)
);
}