yeet
This commit is contained in:
88
node_modules/@react-native-community/cli/build/commands/bundle/assetPathUtils.js
generated
vendored
Normal file
88
node_modules/@react-native-community/cli/build/commands/bundle/assetPathUtils.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* FIXME: using number to represent discrete scale numbers is fragile in essence because of
|
||||
* floating point numbers imprecision.
|
||||
*/
|
||||
function getAndroidAssetSuffix(scale) {
|
||||
switch (scale) {
|
||||
case 0.75:
|
||||
return 'ldpi';
|
||||
|
||||
case 1:
|
||||
return 'mdpi';
|
||||
|
||||
case 1.5:
|
||||
return 'hdpi';
|
||||
|
||||
case 2:
|
||||
return 'xhdpi';
|
||||
|
||||
case 3:
|
||||
return 'xxhdpi';
|
||||
|
||||
case 4:
|
||||
return 'xxxhdpi';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
} // See https://developer.android.com/guide/topics/resources/drawable-resource.html
|
||||
|
||||
|
||||
const drawableFileTypes = new Set(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);
|
||||
|
||||
function getAndroidResourceFolderName(asset, scale) {
|
||||
if (!drawableFileTypes.has(asset.type)) {
|
||||
return 'raw';
|
||||
}
|
||||
|
||||
const suffix = getAndroidAssetSuffix(scale);
|
||||
|
||||
if (!suffix) {
|
||||
throw new Error(`Don't know which android drawable suffix to use for asset: ${JSON.stringify(asset)}`);
|
||||
}
|
||||
|
||||
const androidFolder = `drawable-${suffix}`;
|
||||
return androidFolder;
|
||||
}
|
||||
|
||||
function getAndroidResourceIdentifier(asset) {
|
||||
const folderPath = getBasePath(asset);
|
||||
return `${folderPath}/${asset.name}`.toLowerCase().replace(/\//g, '_') // Encode folder structure in file name
|
||||
.replace(/([^a-z0-9_])/g, '') // Remove illegal chars
|
||||
.replace(/^assets_/, ''); // Remove "assets_" prefix
|
||||
}
|
||||
|
||||
function getBasePath(asset) {
|
||||
let basePath = asset.httpServerLocation;
|
||||
|
||||
if (basePath[0] === '/') {
|
||||
basePath = basePath.substr(1);
|
||||
}
|
||||
|
||||
return basePath;
|
||||
}
|
||||
|
||||
var _default = {
|
||||
getAndroidAssetSuffix,
|
||||
getAndroidResourceFolderName,
|
||||
getAndroidResourceIdentifier,
|
||||
getBasePath
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=assetPathUtils.js.map
|
124
node_modules/@react-native-community/cli/build/commands/bundle/buildBundle.js
generated
vendored
Normal file
124
node_modules/@react-native-community/cli/build/commands/bundle/buildBundle.js
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _Server() {
|
||||
const data = _interopRequireDefault(require("metro/src/Server"));
|
||||
|
||||
_Server = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _bundle() {
|
||||
const data = _interopRequireDefault(require("metro/src/shared/output/bundle"));
|
||||
|
||||
_bundle = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _saveAssets = _interopRequireDefault(require("./saveAssets"));
|
||||
|
||||
var _loadMetroConfig = _interopRequireDefault(require("../../tools/loadMetroConfig"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
// @ts-ignore - no typed definition for the package
|
||||
// @ts-ignore - no typed definition for the package
|
||||
async function buildBundle(args, ctx, output = _bundle().default) {
|
||||
const config = await (0, _loadMetroConfig.default)(ctx, {
|
||||
maxWorkers: args.maxWorkers,
|
||||
resetCache: args.resetCache,
|
||||
config: args.config
|
||||
});
|
||||
|
||||
if (config.resolver.platforms.indexOf(args.platform) === -1) {
|
||||
_cliTools().logger.error(`Invalid platform ${args.platform ? `"${_chalk().default.bold(args.platform)}" ` : ''}selected.`);
|
||||
|
||||
_cliTools().logger.info(`Available platforms are: ${config.resolver.platforms.map(x => `"${_chalk().default.bold(x)}"`).join(', ')}. If you are trying to bundle for an out-of-tree platform, it may not be installed.`);
|
||||
|
||||
throw new Error('Bundling failed');
|
||||
} // This is used by a bazillion of npm modules we don't control so we don't
|
||||
// have other choice than defining it as an env variable here.
|
||||
|
||||
|
||||
process.env.NODE_ENV = args.dev ? 'development' : 'production';
|
||||
let sourceMapUrl = args.sourcemapOutput;
|
||||
|
||||
if (sourceMapUrl && !args.sourcemapUseAbsolutePath) {
|
||||
sourceMapUrl = _path().default.basename(sourceMapUrl);
|
||||
}
|
||||
|
||||
const requestOpts = {
|
||||
entryFile: args.entryFile,
|
||||
sourceMapUrl,
|
||||
dev: args.dev,
|
||||
minify: args.minify !== undefined ? args.minify : !args.dev,
|
||||
platform: args.platform
|
||||
};
|
||||
const server = new (_Server().default)(config);
|
||||
|
||||
try {
|
||||
const bundle = await output.build(server, requestOpts);
|
||||
await output.save(bundle, args, _cliTools().logger.info); // Save the assets of the bundle
|
||||
|
||||
const outputAssets = await server.getAssets({ ..._Server().default.DEFAULT_BUNDLE_OPTIONS,
|
||||
...requestOpts,
|
||||
bundleType: 'todo'
|
||||
}); // When we're done saving bundle output and the assets, we're done.
|
||||
|
||||
return await (0, _saveAssets.default)(outputAssets, args.platform, args.assetsDest);
|
||||
} finally {
|
||||
server.end();
|
||||
}
|
||||
}
|
||||
|
||||
var _default = buildBundle;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=buildBundle.js.map
|
42
node_modules/@react-native-community/cli/build/commands/bundle/bundle.js
generated
vendored
Normal file
42
node_modules/@react-native-community/cli/build/commands/bundle/bundle.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.withOutput = exports.default = void 0;
|
||||
|
||||
var _buildBundle = _interopRequireDefault(require("./buildBundle"));
|
||||
|
||||
var _bundleCommandLineArgs = _interopRequireDefault(require("./bundleCommandLineArgs"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builds the bundle starting to look for dependencies at the given entry path.
|
||||
*/
|
||||
function bundleWithOutput(_, config, args, output) // untyped metro/src/shared/output/bundle or metro/src/shared/output/RamBundle
|
||||
{
|
||||
return (0, _buildBundle.default)(args, config, output);
|
||||
}
|
||||
|
||||
var _default = {
|
||||
name: 'bundle',
|
||||
description: 'builds the javascript bundle for offline use',
|
||||
func: bundleWithOutput,
|
||||
options: _bundleCommandLineArgs.default,
|
||||
// Used by `ramBundle.js`
|
||||
withOutput: bundleWithOutput
|
||||
};
|
||||
exports.default = _default;
|
||||
const withOutput = bundleWithOutput;
|
||||
exports.withOutput = withOutput;
|
||||
|
||||
//# sourceMappingURL=bundle.js.map
|
85
node_modules/@react-native-community/cli/build/commands/bundle/bundleCommandLineArgs.js
generated
vendored
Normal file
85
node_modules/@react-native-community/cli/build/commands/bundle/bundleCommandLineArgs.js
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
var _default = [{
|
||||
name: '--entry-file <path>',
|
||||
description: 'Path to the root JS file, either absolute or relative to JS root'
|
||||
}, {
|
||||
name: '--platform [string]',
|
||||
description: 'Either "ios" or "android"',
|
||||
default: 'ios'
|
||||
}, {
|
||||
name: '--transformer [string]',
|
||||
description: 'Specify a custom transformer to be used'
|
||||
}, {
|
||||
name: '--dev [boolean]',
|
||||
description: 'If false, warnings are disabled and the bundle is minified',
|
||||
parse: val => val !== 'false',
|
||||
default: true
|
||||
}, {
|
||||
name: '--minify [boolean]',
|
||||
description: 'Allows overriding whether bundle is minified. This defaults to ' + 'false if dev is true, and true if dev is false. Disabling minification ' + 'can be useful for speeding up production builds for testing purposes.',
|
||||
parse: val => val !== 'false'
|
||||
}, {
|
||||
name: '--bundle-output <string>',
|
||||
description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle'
|
||||
}, {
|
||||
name: '--bundle-encoding [string]',
|
||||
description: 'Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).',
|
||||
default: 'utf8'
|
||||
}, {
|
||||
name: '--max-workers [number]',
|
||||
description: 'Specifies the maximum number of workers the worker-pool ' + 'will spawn for transforming files. This defaults to the number of the ' + 'cores available on your machine.',
|
||||
parse: workers => Number(workers)
|
||||
}, {
|
||||
name: '--sourcemap-output [string]',
|
||||
description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map'
|
||||
}, {
|
||||
name: '--sourcemap-sources-root [string]',
|
||||
description: "Path to make sourcemap's sources entries relative to, ex. /root/dir"
|
||||
}, {
|
||||
name: '--sourcemap-use-absolute-path',
|
||||
description: 'Report SourceMapURL using its full path',
|
||||
default: false
|
||||
}, {
|
||||
name: '--assets-dest [string]',
|
||||
description: 'Directory name where to store assets referenced in the bundle'
|
||||
}, {
|
||||
name: '--reset-cache',
|
||||
description: 'Removes cached files',
|
||||
default: false
|
||||
}, {
|
||||
name: '--read-global-cache',
|
||||
description: 'Try to fetch transformed JS code from the global cache, if configured.',
|
||||
default: false
|
||||
}, {
|
||||
name: '--config [string]',
|
||||
description: 'Path to the CLI configuration file',
|
||||
parse: val => _path().default.resolve(val)
|
||||
}];
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=bundleCommandLineArgs.js.map
|
53
node_modules/@react-native-community/cli/build/commands/bundle/filterPlatformAssetScales.js
generated
vendored
Normal file
53
node_modules/@react-native-community/cli/build/commands/bundle/filterPlatformAssetScales.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
const ALLOWED_SCALES = {
|
||||
ios: [1, 2, 3]
|
||||
};
|
||||
|
||||
function filterPlatformAssetScales(platform, scales) {
|
||||
const whitelist = ALLOWED_SCALES[platform];
|
||||
|
||||
if (!whitelist) {
|
||||
return scales;
|
||||
}
|
||||
|
||||
const result = scales.filter(scale => whitelist.indexOf(scale) > -1);
|
||||
|
||||
if (result.length === 0 && scales.length > 0) {
|
||||
// No matching scale found, but there are some available. Ideally we don't
|
||||
// want to be in this situation and should throw, but for now as a fallback
|
||||
// let's just use the closest larger image
|
||||
const maxScale = whitelist[whitelist.length - 1];
|
||||
|
||||
for (const scale of scales) {
|
||||
if (scale > maxScale) {
|
||||
result.push(scale);
|
||||
break;
|
||||
}
|
||||
} // There is no larger scales available, use the largest we have
|
||||
|
||||
|
||||
if (result.length === 0) {
|
||||
result.push(scales[scales.length - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var _default = filterPlatformAssetScales;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=filterPlatformAssetScales.js.map
|
40
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathAndroid.js
generated
vendored
Normal file
40
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathAndroid.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _assetPathUtils = _interopRequireDefault(require("./assetPathUtils"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function getAssetDestPathAndroid(asset, scale) {
|
||||
const androidFolder = _assetPathUtils.default.getAndroidResourceFolderName(asset, scale);
|
||||
|
||||
const fileName = _assetPathUtils.default.getAndroidResourceIdentifier(asset);
|
||||
|
||||
return _path().default.join(androidFolder, `${fileName}.${asset.type}`);
|
||||
}
|
||||
|
||||
var _default = getAssetDestPathAndroid;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=getAssetDestPathAndroid.js.map
|
39
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathIOS.js
generated
vendored
Normal file
39
node_modules/@react-native-community/cli/build/commands/bundle/getAssetDestPathIOS.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function getAssetDestPathIOS(asset, scale) {
|
||||
const suffix = scale === 1 ? '' : `@${scale}x`;
|
||||
const fileName = `${asset.name + suffix}.${asset.type}`;
|
||||
return _path().default.join( // Assets can have relative paths outside of the project root.
|
||||
// Replace `../` with `_` to make sure they don't end up outside of
|
||||
// the expected assets directory.
|
||||
asset.httpServerLocation.substr(1).replace(/\.\.\//g, '_'), fileName);
|
||||
}
|
||||
|
||||
var _default = getAssetDestPathIOS;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=getAssetDestPathIOS.js.map
|
52
node_modules/@react-native-community/cli/build/commands/bundle/ramBundle.js
generated
vendored
Normal file
52
node_modules/@react-native-community/cli/build/commands/bundle/ramBundle.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _RamBundle() {
|
||||
const data = _interopRequireDefault(require("metro/src/shared/output/RamBundle"));
|
||||
|
||||
_RamBundle = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _bundle = require("./bundle");
|
||||
|
||||
var _bundleCommandLineArgs = _interopRequireDefault(require("./bundleCommandLineArgs"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
// @ts-ignore - no typed definition for the package
|
||||
|
||||
/**
|
||||
* Builds the bundle starting to look for dependencies at the given entry path.
|
||||
*/
|
||||
function ramBundle(argv, config, args) {
|
||||
return (0, _bundle.withOutput)(argv, config, args, _RamBundle().default);
|
||||
}
|
||||
|
||||
var _default = {
|
||||
name: 'ram-bundle',
|
||||
description: 'builds javascript as a "Random Access Module" bundle for offline use',
|
||||
func: ramBundle,
|
||||
options: _bundleCommandLineArgs.default.concat({
|
||||
name: '--indexed-ram-bundle',
|
||||
description: 'Force the "Indexed RAM" bundle file format, even when building for android',
|
||||
default: false
|
||||
})
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=ramBundle.js.map
|
138
node_modules/@react-native-community/cli/build/commands/bundle/saveAssets.js
generated
vendored
Normal file
138
node_modules/@react-native-community/cli/build/commands/bundle/saveAssets.js
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _mkdirp() {
|
||||
const data = _interopRequireDefault(require("mkdirp"));
|
||||
|
||||
_mkdirp = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _filterPlatformAssetScales = _interopRequireDefault(require("./filterPlatformAssetScales"));
|
||||
|
||||
var _getAssetDestPathAndroid = _interopRequireDefault(require("./getAssetDestPathAndroid"));
|
||||
|
||||
var _getAssetDestPathIOS = _interopRequireDefault(require("./getAssetDestPathIOS"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function saveAssets(assets, platform, assetsDest) {
|
||||
if (!assetsDest) {
|
||||
_cliTools().logger.warn('Assets destination folder is not set, skipping...');
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const getAssetDestPath = platform === 'android' ? _getAssetDestPathAndroid.default : _getAssetDestPathIOS.default;
|
||||
const filesToCopy = Object.create(null); // Map src -> dest
|
||||
|
||||
assets.forEach(asset => {
|
||||
const validScales = new Set((0, _filterPlatformAssetScales.default)(platform, asset.scales));
|
||||
asset.scales.forEach((scale, idx) => {
|
||||
if (!validScales.has(scale)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const src = asset.files[idx];
|
||||
|
||||
const dest = _path().default.join(assetsDest, getAssetDestPath(asset, scale));
|
||||
|
||||
filesToCopy[src] = dest;
|
||||
});
|
||||
});
|
||||
return copyAll(filesToCopy);
|
||||
}
|
||||
|
||||
function copyAll(filesToCopy) {
|
||||
const queue = Object.keys(filesToCopy);
|
||||
|
||||
if (queue.length === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
_cliTools().logger.info(`Copying ${queue.length} asset files`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const copyNext = error => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (queue.length === 0) {
|
||||
_cliTools().logger.info('Done copying assets');
|
||||
|
||||
resolve();
|
||||
} else {
|
||||
// queue.length === 0 is checked in previous branch, so this is string
|
||||
const src = queue.shift();
|
||||
const dest = filesToCopy[src];
|
||||
copy(src, dest, copyNext);
|
||||
}
|
||||
};
|
||||
|
||||
copyNext();
|
||||
});
|
||||
}
|
||||
|
||||
function copy(src, dest, callback) {
|
||||
const destDir = _path().default.dirname(dest);
|
||||
|
||||
(0, _mkdirp().default)(destDir, err => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
_fs().default.createReadStream(src).pipe(_fs().default.createWriteStream(dest)).on('finish', callback);
|
||||
});
|
||||
}
|
||||
|
||||
var _default = saveAssets;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=saveAssets.js.map
|
Reference in New Issue
Block a user