Skip to content

Commit

Permalink
Use ES2015 String methods available in Node.js v4
Browse files Browse the repository at this point in the history
  • Loading branch information
insin committed Jan 15, 2017
1 parent 5ea76cb commit 93bc11c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- postcss-loader: v1.2.1 → [v1.2.2](https://github.com/postcss/postcss-loader/blob/master/CHANGELOG.md#122)
- webpack-merge: v2.3.1 → [v2.4.0](https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#240--2017-01-12)

**Internal:**

- Use ES2015 `String` methods available in Node.js v4 instead of `String.prototype.indexOf` comparisons.

# 0.14.1 / 2017-01-13

**Fixed:**
Expand Down
8 changes: 4 additions & 4 deletions src/createWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import merge from 'webpack-merge'
import HashedModuleIdsPlugin from '../vendor/HashedModuleIdsPlugin'
import createBabelConfig from './createBabelConfig'
import debug from './debug'
import {deepToString, endsWith, typeOf} from './utils'
import {deepToString, typeOf} from './utils'
import StatusPlugin from './WebpackStatusPlugin'

// Top-level property names reserved for webpack config
Expand Down Expand Up @@ -69,7 +69,7 @@ export let loaderConfigFactory = (buildConfig, userConfig) =>
*/
export let styleLoaderName = (prefix) =>
(name) => {
if (prefix && endsWith(prefix, name)) {
if (prefix && prefix.endsWith(name)) {
return prefix
}
return prefix ? `${prefix}-${name}` : name
Expand Down Expand Up @@ -254,7 +254,7 @@ function injectManifestPlugin() {
this.plugin('compilation', (compilation) => {
compilation.plugin('html-webpack-plugin-before-html-processing', (data, cb) => {
Object.keys(compilation.assets).forEach(key => {
if (key.indexOf('manifest.') !== 0) return
if (!key.startsWith('manifest.')) return
let {children} = compilation.assets[key]
if (children && children[0]) {
data.html = data.html.replace(
Expand Down Expand Up @@ -346,7 +346,7 @@ export function createPlugins(server, buildConfig = {}, userConfig = {}) {
minChunks(module, count) {
return (
module.resource &&
module.resource.indexOf('node_modules') !== -1
module.resource.includes('node_modules')
)
}
}))
Expand Down
7 changes: 0 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ export function deepToString(object) {
return util.inspect(object, {colors: true, depth: null})
}

/**
* String.prototype.endsWith() is behind the --harmony flag in Node.js v0.12.
*/
export function endsWith(s1, s2) {
return s1.lastIndexOf(s2) === s1.length - s2.length
}

/**
* Get a list of nwb plugin names passed as arguments.
* @param {Object} args parsed arguments.
Expand Down
2 changes: 1 addition & 1 deletion src/webpackUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function formatMessage(message) {
}

function isLikelyASyntaxError(message) {
return message.indexOf(FRIENDLY_SYNTAX_ERROR_LABEL) !== -1
return message.includes(FRIENDLY_SYNTAX_ERROR_LABEL)
}

function formatMessages(messages, type) {
Expand Down

0 comments on commit 93bc11c

Please sign in to comment.