Skip to content

Commit

Permalink
change 'require' to 'import'
Browse files Browse the repository at this point in the history
  • Loading branch information
hafizalfaza authored and axe312ger committed Mar 2, 2019
1 parent faab47a commit 5f6ee69
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 40 deletions.
6 changes: 3 additions & 3 deletions scripts/bundle-vendor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { execSync } = require('child_process')
const { existsSync } = require('fs')
const { resolve } = require('path')
import { execSync } from 'child-process'
import { existsSync } from 'fs'
import { resolve } from 'path'

const builds = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const yargs = require('yargs')
import yargs from 'yargs'

const sqip = require('./index.js')
import sqip from './index.js'

const { argv } = yargs
.usage('\nUsage: sqip --input [path]')
Expand Down
10 changes: 3 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ import path from 'path'

import fs from 'fs-extra'

const {
encodeBase64,
getDimensions,
printFinalResult
} = require('./utils/helpers')
const { checkForPrimitive, runPrimitive } = require('./utils/primitive')
const { runSVGO, prepareSVG, applyBlurFilter } = require('./utils/svg')
import { encodeBase64, getDimensions, printFinalResult } from './utils/helpers'
import { checkForPrimitive, runPrimitive } from './utils/primitive'
import { runSVGO, prepareSVG, applyBlurFilter } from './utils/svg'

export default async function sqip(options) {
// Build configuration based on passed options and default options
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const sizeOf = require('image-size')
import sizeOf from 'image-size'

// In case the user the did not provide the --output switch and is thus opting for the default stdout output inside an <img>, prepare the base64 encoded version of the SVG
const encodeBase64 = rawSVG => Buffer.from(rawSVG).toString('base64')
Expand Down
4 changes: 2 additions & 2 deletions src/utils/svg.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const SVGO = require('svgo')
const cheerio = require('cheerio')
import SVGO from 'svgo'
import cheerio from 'cheerio'

const PRIMITIVE_SVG_ELEMENTS = 'circle, ellipse, line, polygon, path, rect, g'

Expand Down
10 changes: 5 additions & 5 deletions test/e2e/e2e.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { readFileSync } = require('fs')
const { resolve } = require('path')
const { tmpdir } = require('os')
import { readFileSync } from 'fs'
import { resolve } from 'path'
import { tmpdir } from 'os'

const cheerio = require('cheerio')
const nixt = require('nixt')
import cheerio from 'cheerio'
import nixt from 'nixt'

const inputFile = resolve(__dirname, '..', '..', 'demo', 'beach.jpg')
const cliCmd = `node ${resolve(__dirname, '..', '..', 'dist', 'cli.js')}`
Expand Down
8 changes: 4 additions & 4 deletions test/unit/utils/helpers.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { readFileSync } = require('fs')
const { resolve } = require('path')
import { readFileSync } from 'fs'
import { resolve } from 'path'

const {
import {
encodeBase64,
getDimensions,
printFinalResult
} = require('../../../src/utils/helpers')
} from '../../../src/utils/helpers'

const rawSVG = readFileSync(resolve(__dirname, '../../../demo/beach-sqip.svg'))

Expand Down
14 changes: 5 additions & 9 deletions test/unit/utils/primitive.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
const path = require('path')
import path from 'path'
import execaMock from 'execa'
import fsMock from 'fs-extra'
import osMock from 'os'

const execaMock = require('execa')
const fsMock = require('fs-extra')
const osMock = require('os')

const {
checkForPrimitive,
runPrimitive
} = require('../../../src/utils/primitive')
import { checkForPrimitive, runPrimitive } from '../../../src/utils/primitive'

jest.mock('execa')

Expand Down
9 changes: 2 additions & 7 deletions test/unit/utils/svg.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
const SVGO = require('svgo')

const {
runSVGO,
prepareSVG,
applyBlurFilter
} = require('../../../src/utils/svg')
import SVGO from 'svgo'
import { runSVGO, prepareSVG, applyBlurFilter } from '../../../src/utils/svg'

jest.mock('svgo')

Expand Down

0 comments on commit 5f6ee69

Please sign in to comment.