utils.js — react Source File
Architecture documentation for utils.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
'use strict';
const ncp = require('ncp').ncp;
const path = require('path');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');
const exec = require('child_process').exec;
const targz = require('targz');
function asyncCopyTo(from, to) {
return asyncMkDirP(path.dirname(to)).then(
() =>
new Promise((resolve, reject) => {
ncp(from, to, error => {
if (error) {
// Wrap to have a useful stack trace.
reject(new Error(error));
} else {
// Wait for copied files to exist; ncp() sometimes completes prematurely.
// For more detail, see github.com/facebook/react/issues/22323
// Also github.com/AvianFlu/ncp/issues/127
setTimeout(resolve, 10);
}
});
})
);
}
function asyncExecuteCommand(command) {
return new Promise((resolve, reject) =>
exec(command, (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve(stdout);
})
);
}
function asyncExtractTar(options) {
return new Promise((resolve, reject) =>
targz.decompress(options, error => {
if (error) {
reject(error);
return;
}
resolve();
})
);
}
function asyncMkDirP(filepath) {
return new Promise((resolve, reject) =>
mkdirp(filepath, error => {
if (error) {
reject(error);
return;
}
resolve();
})
);
}
function asyncRimRaf(filepath) {
return new Promise((resolve, reject) =>
rimraf(filepath, error => {
if (error) {
reject(error);
return;
}
resolve();
})
);
}
function resolvePath(filepath) {
if (filepath[0] === '~') {
return path.join(process.env.HOME, filepath.slice(1));
} else {
return path.resolve(filepath);
}
}
module.exports = {
asyncCopyTo,
resolvePath,
asyncExecuteCommand,
asyncExtractTar,
asyncMkDirP,
asyncRimRaf,
};
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does utils.js do?
utils.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in utils.js?
utils.js defines 6 function(s): asyncCopyTo, asyncExecuteCommand, asyncExtractTar, asyncMkDirP, asyncRimRaf, resolvePath.
Where is utils.js in the architecture?
utils.js is located at scripts/rollup/utils.js (domain: BabelCompiler, subdomain: Entrypoint, directory: scripts/rollup).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free