Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Revert "Merge pull request #13756 from NejcZdovc/fix/#13754-regex"
Browse files Browse the repository at this point in the history
This reverts commit 06c774b.
  • Loading branch information
bsclifton committed Apr 12, 2018
1 parent 3b161b3 commit c1e8ba9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 45 deletions.
4 changes: 2 additions & 2 deletions app/cmdLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const fs = require('fs')
const path = require('path')

const isDarwin = process.platform === 'darwin'
const promoCodeFilenameRegex = /-([a-zA-Z\d]{3}\d{3})\s?(?:\(\d+\))?$/g
const debugTabEventsFlagName = '--debug-tab-events'

let appInitialized = false
Expand Down Expand Up @@ -165,9 +166,8 @@ const api = module.exports = {
// parse promo code from installer path
// first, get filename
const fileName = path.win32.parse(installerPath).name
const promoCodeFilenameRegex = /-(([a-zA-Z\d]{3}\d{3})|([a-zA-Z]{1,}-[a-zA-Z]{1,}))\s?(?:\(\d+\))?$/g
const matches = promoCodeFilenameRegex.exec(fileName)
if (matches && matches.length > 1) {
if (matches && matches.length === 2) {
return matches[1]
}
return null
Expand Down
2 changes: 1 addition & 1 deletion build/pkg-scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ installationPath=$2
# TODO: ugly to assume the name of the app, especially with multi-channel.
# Luckily for now, release channel is the only channel with a pkg installer.
installationAppPath="$installationPath/Brave.app"
installerPathPromoCodeRegex='.+-(([a-zA-Z0-9]{3}[0-9]{3})|([a-zA-Z]{1,}-[a-zA-Z]{1,}))([[:blank:]]?\([0-9]+\))?\.pkg$'
installerPathPromoCodeRegex='.+-([a-zA-Z0-9]{3}[0-9]{3})([[:blank:]]?\([0-9]+\))?\.pkg$'
userDataDir="$HOME/Library/Application Support/brave"
promoCodePath="$userDataDir/promoCode"
# pkg runs this script as root so we need to get current username
Expand Down
17 changes: 0 additions & 17 deletions build/pkg-scripts/postinstall-test.sh

This file was deleted.

25 changes: 0 additions & 25 deletions test/unit/app/cmdLineTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,6 @@ describe('cmdLine', function () {
const result = this.cmdLine.getFirstRunPromoCode(args)
assert.equal(result, promoCode)
})

it('finds and parses promo code when we have multiple downloads', function () {
const promoCode = 'pem001 (1)'
const validPromoCodeInstallerPath = `d:\\my\\location\\on-disk\\in-a-folder-tes301\\Setup-Brave-x64-${promoCode}.exe`
const args = [...initialArgs, key, validPromoCodeInstallerPath, '--other', 'arg', '--and-another']
const result = this.cmdLine.getFirstRunPromoCode(args)
assert.equal(result, 'pem001')
})

it('finds and parses promo code 2', function () {
const promoCode = 'org-name'
const validPromoCodeInstallerPath = `d:\\my\\location\\on-disk\\in-a-folder-tes301\\Setup-Brave-x64-${promoCode}.exe`
const args = [...initialArgs, key, validPromoCodeInstallerPath, '--other', 'arg', '--and-another']
const result = this.cmdLine.getFirstRunPromoCode(args)
assert.equal(result, promoCode)
})

it('finds and parses promo code 2 when we have multiple downloads', function () {
const promoCode = 'org-name (1)'
const validPromoCodeInstallerPath = `d:\\my\\location\\on-disk\\in-a-folder-tes301\\Setup-Brave-x64-${promoCode}.exe`
const args = [...initialArgs, key, validPromoCodeInstallerPath, '--other', 'arg', '--and-another']
const result = this.cmdLine.getFirstRunPromoCode(args)
assert.equal(result, 'org-name')
})

it(`does not find promo code when there isn't one`, function () {
const noPromoCodeInstallerPath = `d:\\my\\location\\on-disk\\in-a-folder-tes301\\Setup-Brave-x64.exe`
const args = [...initialArgs, key, noPromoCodeInstallerPath, '--other', 'arg', '--and-another']
Expand Down

0 comments on commit c1e8ba9

Please sign in to comment.