mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-20 04:24:44 +07:00
Improve code quality and write tests
This commit is contained in:
22
node_modules/@babel/plugin-transform-template-literals/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/plugin-transform-template-literals/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
node_modules/@babel/plugin-transform-template-literals/README.md
generated
vendored
Normal file
19
node_modules/@babel/plugin-transform-template-literals/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# @babel/plugin-transform-template-literals
|
||||
|
||||
> Compile ES2015 template literals to ES5
|
||||
|
||||
See our website [@babel/plugin-transform-template-literals](https://babeljs.io/docs/en/next/babel-plugin-transform-template-literals.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-template-literals
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-transform-template-literals --dev
|
||||
```
|
148
node_modules/@babel/plugin-transform-template-literals/lib/index.js
generated
vendored
Normal file
148
node_modules/@babel/plugin-transform-template-literals/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _helperPluginUtils() {
|
||||
const data = require("@babel/helper-plugin-utils");
|
||||
|
||||
_helperPluginUtils = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _core() {
|
||||
const data = require("@babel/core");
|
||||
|
||||
_core = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _default = (0, _helperPluginUtils().declare)((api, options) => {
|
||||
api.assertVersion(7);
|
||||
const {
|
||||
loose
|
||||
} = options;
|
||||
let helperName = "taggedTemplateLiteral";
|
||||
if (loose) helperName += "Loose";
|
||||
|
||||
function buildConcatCallExpressions(items) {
|
||||
let avail = true;
|
||||
return items.reduce(function (left, right) {
|
||||
let canBeInserted = _core().types.isLiteral(right);
|
||||
|
||||
if (!canBeInserted && avail) {
|
||||
canBeInserted = true;
|
||||
avail = false;
|
||||
}
|
||||
|
||||
if (canBeInserted && _core().types.isCallExpression(left)) {
|
||||
left.arguments.push(right);
|
||||
return left;
|
||||
}
|
||||
|
||||
return _core().types.callExpression(_core().types.memberExpression(left, _core().types.identifier("concat")), [right]);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
name: "transform-template-literals",
|
||||
visitor: {
|
||||
TaggedTemplateExpression(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
const {
|
||||
quasi
|
||||
} = node;
|
||||
const strings = [];
|
||||
const raws = [];
|
||||
let isStringsRawEqual = true;
|
||||
|
||||
for (const elem of quasi.quasis) {
|
||||
const {
|
||||
raw,
|
||||
cooked
|
||||
} = elem.value;
|
||||
const value = cooked == null ? path.scope.buildUndefinedNode() : _core().types.stringLiteral(cooked);
|
||||
strings.push(value);
|
||||
raws.push(_core().types.stringLiteral(raw));
|
||||
|
||||
if (raw !== cooked) {
|
||||
isStringsRawEqual = false;
|
||||
}
|
||||
}
|
||||
|
||||
const scope = path.scope.getProgramParent();
|
||||
const templateObject = scope.generateUidIdentifier("templateObject");
|
||||
const helperId = this.addHelper(helperName);
|
||||
const callExpressionInput = [_core().types.arrayExpression(strings)];
|
||||
|
||||
if (!isStringsRawEqual) {
|
||||
callExpressionInput.push(_core().types.arrayExpression(raws));
|
||||
}
|
||||
|
||||
const lazyLoad = _core().template.ast`
|
||||
function ${templateObject}() {
|
||||
const data = ${_core().types.callExpression(helperId, callExpressionInput)};
|
||||
${templateObject} = function() { return data };
|
||||
return data;
|
||||
}
|
||||
`;
|
||||
scope.path.unshiftContainer("body", lazyLoad);
|
||||
path.replaceWith(_core().types.callExpression(node.tag, [_core().types.callExpression(_core().types.cloneNode(templateObject), []), ...quasi.expressions]));
|
||||
},
|
||||
|
||||
TemplateLiteral(path) {
|
||||
const nodes = [];
|
||||
const expressions = path.get("expressions");
|
||||
let index = 0;
|
||||
|
||||
for (const elem of path.node.quasis) {
|
||||
if (elem.value.cooked) {
|
||||
nodes.push(_core().types.stringLiteral(elem.value.cooked));
|
||||
}
|
||||
|
||||
if (index < expressions.length) {
|
||||
const expr = expressions[index++];
|
||||
const node = expr.node;
|
||||
|
||||
if (!_core().types.isStringLiteral(node, {
|
||||
value: ""
|
||||
})) {
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const considerSecondNode = !loose || !_core().types.isStringLiteral(nodes[1]);
|
||||
|
||||
if (!_core().types.isStringLiteral(nodes[0]) && considerSecondNode) {
|
||||
nodes.unshift(_core().types.stringLiteral(""));
|
||||
}
|
||||
|
||||
let root = nodes[0];
|
||||
|
||||
if (loose) {
|
||||
for (let i = 1; i < nodes.length; i++) {
|
||||
root = _core().types.binaryExpression("+", root, nodes[i]);
|
||||
}
|
||||
} else if (nodes.length > 1) {
|
||||
root = buildConcatCallExpressions(nodes);
|
||||
}
|
||||
|
||||
path.replaceWith(root);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
exports.default = _default;
|
58
node_modules/@babel/plugin-transform-template-literals/package.json
generated
vendored
Normal file
58
node_modules/@babel/plugin-transform-template-literals/package.json
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@babel/plugin-transform-template-literals@7.4.4",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "@babel/plugin-transform-template-literals@7.4.4",
|
||||
"_id": "@babel/plugin-transform-template-literals@7.4.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-mQrEC4TWkhLN0z8ygIvEL9ZEToPhG5K7KDW3pzGqOfIGZ28Jb0POUkeWcoz8HnHvhFy6dwAT1j8OzqN8s804+g==",
|
||||
"_location": "/@babel/plugin-transform-template-literals",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@babel/plugin-transform-template-literals@7.4.4",
|
||||
"name": "@babel/plugin-transform-template-literals",
|
||||
"escapedName": "@babel%2fplugin-transform-template-literals",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "7.4.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "7.4.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/preset-env"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.4.4.tgz",
|
||||
"_spec": "7.4.4",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"dependencies": {
|
||||
"@babel/helper-annotate-as-pure": "^7.0.0",
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
},
|
||||
"description": "Compile ES2015 template literals to ES5",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
},
|
||||
"gitHead": "2c88694388831b1e5b88e4bbed6781eb2be1edba",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "@babel/plugin-transform-template-literals",
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-template-literals"
|
||||
},
|
||||
"version": "7.4.4"
|
||||
}
|
Reference in New Issue
Block a user