Skip to content

Commit

Permalink
fix: remove lodash.template
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Apr 26, 2024
1 parent 1cf0230 commit 19c27f9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"fs-extra": "^8.1",
"github-slugger": "^1.5.0",
"got": "^13",
"lodash.template": "^4.5.0",
"normalize-package-data": "^3.0.3",
"semver": "^7.6.0",
"sort-package-json": "^2.10.0",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {castArray, compact, sortBy, template, uniqBy} from '../util'
const normalize = require('normalize-package-data')
const columns = Number.parseInt(process.env.COLUMNS!, 10) || 120
const slugify = new (require('github-slugger'))()
const lodashTemplate = require('lodash.template')
import {render} from 'ejs'

interface HelpBaseDerived {
new (config: Interfaces.Config, opts?: Partial<Interfaces.HelpOptions>): HelpBase
Expand Down Expand Up @@ -87,7 +87,7 @@ Customize the code URL prefix by setting oclif.repositoryPrefix in package.json.
this.flags['repository-prefix'] ||
plugin.pjson.oclif.repositoryPrefix ||
'<%- repo %>/blob/v<%- version %>/<%- commandPath %>'
return `_See code: [${label}](${lodashTemplate(template)({c, commandPath, config, repo, version})})_`
return `_See code: [${label}](${render(template, {c, commandPath, config, repo, version})})_`
}

commands(config: Interfaces.Config, commands: Command.Cached[]): string {
Expand Down
5 changes: 2 additions & 3 deletions src/upload-util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {Interfaces} from '@oclif/core'
import {render} from 'ejs'
import {join} from 'node:path'

import {BuildConfig as TarballConfig} from './tarballs/config'

import template = require('lodash.template')

export function commitAWSDir(version: string, sha: string, s3Config: TarballConfig['s3Config']): string {
let s3SubDir = s3Config.folder || ''
if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/') s3SubDir = `${s3SubDir}/`
Expand Down Expand Up @@ -46,7 +45,7 @@ export function templateShortKey(
versioned: '<%- bin %>-v<%- version %>-<%- sha %>-<%- platform %>-<%- arch %><%- ext %>',
win32: '<%- bin %>-v<%- version %>-<%- sha %>-<%- arch %>.exe',
}
return template(templates[type])({...options})
return render(templates[type], {...options})
}

export type DebArch = 'amd64' | 'arm64' | 'armel' | 'i386'
Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Errors} from '@oclif/core'
import {render} from 'ejs'
import {exec as execSync} from 'node:child_process'
import * as crypto from 'node:crypto'
import {createReadStream} from 'node:fs'
Expand All @@ -7,7 +8,6 @@ import {promisify} from 'node:util'

import {log} from './log'
const exec = promisify(execSync)
import lodashTemplate = require('lodash.template')

export function castArray<T>(input?: T | T[]): T[] {
if (input === undefined) return []
Expand Down Expand Up @@ -55,7 +55,7 @@ export function sortBy<T>(arr: T[], fn: (i: T) => Types | Types[]): T[] {
export const template =
(context: object | undefined) =>
(t: string | undefined): string =>
lodashTemplate(t || '')(context)
render(t || '', context)

interface VersionsObject {
[key: string]: string
Expand Down

0 comments on commit 19c27f9

Please sign in to comment.