diff --git a/tools/builder.js b/tools/builder.js index 25793abe50..05a0223246 100644 --- a/tools/builder.js +++ b/tools/builder.js @@ -2,7 +2,6 @@ import {WatchSet, readAndWatchFile, sha1} from './watch.js'; import files from './files.js'; import NpmDiscards from './npm-discards.js'; import {Profile} from './profile.js'; -import {startsWith} from './utils.js'; const ENABLE_IN_PLACE_BUILDER_REPLACEMENT = ! process.env.METEOR_DISABLE_BUILDER_IN_PLACE; @@ -549,7 +548,7 @@ Previous builder: ${previousBuilder.outputPath}, this builder: ${outputPath}` // mark all sub-paths as removed, too paths.forEach((anotherPath) => { - if (startsWith(anotherPath, path + '/')) { + if (anotherPath.startsWith(path + '/')) { removed[anotherPath] = true; } }); diff --git a/tools/commands-packages.js b/tools/commands-packages.js index 2b46587a8f..790f4e53d6 100644 --- a/tools/commands-packages.js +++ b/tools/commands-packages.js @@ -64,16 +64,11 @@ var formatAsList = function (list, options) { return _.map(list, formatter).join(", "); }; -var endsWith = function (s, suffix) { - return s.length >= suffix.length && - s.substr(s.length - suffix.length) === suffix; -}; - var removeIfEndsWith = function (s, suffix) { - if (!endsWith(s, suffix)) { - return s; + if (s.endsWith(suffix)) { + return s.substring(0, s.length - suffix.length); } - return s.substring(0, s.length - suffix.length); + return s; }; var formatArchitecture = function (s) { diff --git a/tools/compiler.js b/tools/compiler.js index 98a39d0f37..728e5210e7 100644 --- a/tools/compiler.js +++ b/tools/compiler.js @@ -15,7 +15,6 @@ var linterPluginModule = require('./linter-plugin.js'); var compileStepModule = require('./compiler-deprecated-compile-step.js'); var Profile = require('./profile.js').Profile; import { SourceProcessorSet } from './build-plugin.js'; -import { startsWith } from './utils.js'; var compiler = exports; @@ -850,7 +849,7 @@ compiler.eachUsedUnibuild = function ( // Note: this code is duplicated in packages/constraint-solver/solver.js export function isIsobuildFeaturePackage(packageName) { - return startsWith(packageName, 'isobuild:'); + return packageName.startsWith('isobuild:'); } export const KNOWN_ISOBUILD_FEATURE_PACKAGES = { diff --git a/tools/isopack.js b/tools/isopack.js index bceb517c26..80896d8658 100644 --- a/tools/isopack.js +++ b/tools/isopack.js @@ -13,7 +13,6 @@ var linterPluginModule = require('./linter-plugin.js'); var buildPluginModule = require('./build-plugin.js'); var Console = require('./console.js').Console; var Profile = require('./profile.js').Profile; -import { endsWith } from './utils.js'; var rejectBadPath = function (p) { if (p.match(/\.\./)) @@ -606,13 +605,13 @@ _.extend(Isopack.prototype, { // Don't let extensions or filenames try to look for directories (in the // way that WatchSet expresses them). - if (extensions && extensions.some(e => endsWith(e, '/'))) { + if (extensions && extensions.some(e => e.endsWith('/'))) { buildmessage.error( `Plugin.${methodName}: extensions may not end in /`); // recover by ignoring return; } - if (filenames && filenames.some(f => endsWith(f, '/'))) { + if (filenames && filenames.some(f => f.endsWith('/'))) { buildmessage.error( `Plugin.${methodName}: filenames may not end in /`); // recover by ignoring diff --git a/tools/main-transpile-wrapper.js b/tools/main-transpile-wrapper.js index cd8b314766..2a67408173 100644 --- a/tools/main-transpile-wrapper.js +++ b/tools/main-transpile-wrapper.js @@ -15,11 +15,12 @@ babelRegister(); // #RemoveInProd this line is removed in isopack.js // run all its callbacks in Fibers. global.Promise = require("meteor-promise"); -// Globally install ES2015-complaint Symbol, Map, and Set, patching the -// native implementations if they are available. +// Install ES2015-complaint polyfills for Symbol, Map, Set, and String, +// patching the native implementations if they are available. require("core-js/es6/symbol"); require("core-js/es6/map"); require("core-js/es6/set"); +require("core-js/es6/string"); // Include helpers from NPM so that the compiler doesn't need to add boilerplate // at the top of every file diff --git a/tools/profile.js b/tools/profile.js index a98f459395..c0e27a217c 100644 --- a/tools/profile.js +++ b/tools/profile.js @@ -256,10 +256,6 @@ var print = function (indent, text) { console.log(prefix + spaces(indent * 2) + text); }; -var startsWith = function (s1, s2) { - return (s1.substr(0, s2.length) === s2); -}; - var isChild = function (entry1, entry2) { return (entry2.length === entry1.length + 1 && _.isEqual(entry1, entry2.slice(0, entry1.length))); diff --git a/tools/tropohouse.js b/tools/tropohouse.js index a6032acb92..ea3ac0ecb9 100644 --- a/tools/tropohouse.js +++ b/tools/tropohouse.js @@ -214,8 +214,8 @@ _.extend(exports.Tropohouse.prototype, { } var latestMeteorSymlink = self.latestMeteorSymlink(); - if (utils.startsWith(latestMeteorSymlink, - packagesDirectoryName + files.pathSep)) { + if (latestMeteorSymlink.startsWith(packagesDirectoryName + + files.pathSep)) { var rest = latestMeteorSymlink.substr( packagesDirectoryName.length + files.pathSep.length); @@ -247,7 +247,7 @@ _.extend(exports.Tropohouse.prototype, { // it points to. if (packageEscaped === latestToolPackageEscaped && (version === latestToolVersion || - utils.startsWith(version, '.' + latestToolVersion + '.'))) { + version.startsWith('.' + latestToolVersion + '.'))) { return; } @@ -255,7 +255,7 @@ _.extend(exports.Tropohouse.prototype, { // operation). if (packageEscaped === currentToolPackageEscaped && (version === currentToolVersion || - utils.startsWith(version, '.' + currentToolVersion + '.'))) { + version.startsWith('.' + currentToolVersion + '.'))) { return; } diff --git a/tools/updater.js b/tools/updater.js index a63e89ce57..2e6d10f54a 100644 --- a/tools/updater.js +++ b/tools/updater.js @@ -170,7 +170,7 @@ var updateMeteorToolSymlink = function (printErrors) { var localLatestReleaseLink = tropohouse.default.latestMeteorSymlink(); - if (! utils.startsWith(localLatestReleaseLink, relativeToolPath + files.pathSep)) { + if (! localLatestReleaseLink.startsWith(relativeToolPath + files.pathSep)) { // The latest release from the catalog is not where the ~/.meteor/meteor // symlink points to. Let's make sure we have that release on disk, // and then update the symlink. diff --git a/tools/utils.js b/tools/utils.js index 71dda67b64..c4bcf5131d 100644 --- a/tools/utils.js +++ b/tools/utils.js @@ -384,17 +384,6 @@ exports.isDirectory = function (dir) { return stats.isDirectory(); }; -// XXX from Underscore.String (http://epeli.github.com/underscore.string/) -exports.startsWith = function(str, starts) { - return str.length >= starts.length && - str.substring(0, starts.length) === starts; -}; - -exports.endsWith = function(str, ends) { - return str.length >= ends.length && - str.substring(str.length - ends.length) === ends; -}; - // Options: noPrefix: do not display 'Meteor ' in front of the version number. exports.displayRelease = function (track, version, options) { var catalog = require('./catalog.js');