Skip to content

Commit

Permalink
refactor: remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris authored and sgtcoolguy committed Nov 11, 2019
1 parent 5f9a7ea commit ab5df03
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 54 deletions.
52 changes: 0 additions & 52 deletions build/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,56 +305,4 @@ Utils.installSDK = async function (versionTag, symlinkIfPossible = false) {
});
};

/**
* Given an npm module id, this will copy it and it's dependencies to a
* destination "node_modules" folder.
* Note that all of the packages are copied to the top-level of "node_modules",
* not nested!
* Also, to shortcut the logic, if the original package has been copied to the
* destination we will *not* attempt to read it's dependencies and ensure those
* are copied as well! So if the modules version changes or something goes
* haywire and the copies aren't full finished due to a failure, the only way to
* get right is to clean the destination "node_modules" dir before rebuilding.
*
* @param {String} moduleId The npm package/module to copy (along with it's dependencies)
* @param {String} destNodeModulesDir path to the destination "node_modules" folder
* @param {Array} [paths=[]] Array of additional paths to pass to require.resolve() (in addition to those from require.resolve.paths(moduleId))
*/
function copyPackageAndDependencies(moduleId, destNodeModulesDir, paths = []) {
const destPackage = path.join(destNodeModulesDir, moduleId);
if (fs.existsSync(path.join(destPackage, 'package.json'))) {
return; // if the module seems to exist in the destination, just skip it.
}

// copy the dependency's folder over
let pkgJSONPath;
if (require.resolve.paths) {
const thePaths = require.resolve.paths(moduleId);
pkgJSONPath = require.resolve(path.join(moduleId, 'package.json'), { paths: thePaths.concat(paths) });
} else {
pkgJSONPath = require.resolve(path.join(moduleId, 'package.json'));
}
const srcPackage = path.dirname(pkgJSONPath);
const srcPackageNodeModulesDir = path.join(srcPackage, 'node_modules');
for (let i = 0; i < 3; i++) {
fs.copySync(srcPackage, destPackage, {
preserveTimestamps: true,
filter: src => !src.startsWith(srcPackageNodeModulesDir)
});

// Quickly verify package copied, I've experienced occurences where it does not.
// Retry up to three times if it did not copy correctly.
if (fs.existsSync(path.join(destPackage, 'package.json'))) {
break;
}
}

// Now read it's dependencies and recurse on them
const packageJSON = fs.readJSONSync(pkgJSONPath);
for (const dependency in packageJSON.dependencies) {
copyPackageAndDependencies(dependency, destNodeModulesDir, [ srcPackageNodeModulesDir ]);
}
}
Utils.copyPackageAndDependencies = copyPackageAndDependencies;

module.exports = Utils;
3 changes: 1 addition & 2 deletions build/scons-xcode-project-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ async function generateBundle(outputDir) {
const ios = new IOS({ });

await builder.transpile('ios', ios.babelOptions, path.join(outputDir, 'ti.main.js'));

}
// FIXME: Combine common code here and in packager.js!

async function main(tmpBundleDir) {
await fs.emptyDir(tmpBundleDir);
await generateBundle(appDir); // run rollup/babel to generate single bundled ti.main.js in app
Expand Down

0 comments on commit ab5df03

Please sign in to comment.