Skip to content

Commit

Permalink
Windows. Please.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanblock committed Dec 6, 2023
1 parent 50c4412 commit 75f1053
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
23 changes: 13 additions & 10 deletions test/integration/preferences-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
let { join } = require('path')
let { homedir } = require('os')
let test = require('tape')
let sut = join(process.cwd(), 'src', 'index')
let inv = require(sut)
let mockTmp = require('mock-tmp')
let cwd = process.cwd()
let testLibPath = join(cwd, 'test', 'lib')
let { getHomedir } = require(testLibPath)
let sut = join(cwd, 'src', 'index')
let inv = require(sut)

let mock = join(process.cwd(), 'test', 'mock')
let _homedir = getHomedir()
let mock = join(cwd, 'test', 'mock')
let arc = '@app\nappname\n@events\nan-event' // Not using @http so we can skip ASAP filesystem checks
let reset = () => mockTmp.reset()
let _testing = true, cwd
let _testing = true

/**
* Duplicates some unit tests as part of the larger whole integration test
Expand Down Expand Up @@ -56,8 +59,8 @@ testing
env_var_1 foo
env_var_2 bar
`
let path = join(homedir(), '.prefs.arc')
cwd = mockTmp({
let path = join(_homedir, '.prefs.arc')
let cwd = mockTmp({
'app.arc': arc,
[path]: prefsText
})
Expand Down Expand Up @@ -198,8 +201,8 @@ staging
production: null,
}
}
let path = join(homedir(), '.prefs.arc')
cwd = mockTmp({
let path = join(_homedir, '.prefs.arc')
let cwd = mockTmp({
'app.arc': arc,
[path]: globalPrefsText,
'preferences.arc': localPrefsText
Expand Down Expand Up @@ -239,7 +242,7 @@ test('Preferences validation errors', async t => {
@env
foo
`
cwd = mockTmp({
let cwd = mockTmp({
'app.arc': arc,
'prefs.arc': prefs,
})
Expand Down
10 changes: 9 additions & 1 deletion test/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
let { homedir } = require('os')
let { is } = require('../../src/lib')

function getHomedir () {
let _homedir = homedir()
if (process.platform === 'win32') _homedir = _homedir.replace(/^[A-Z]:\\/, '')
return _homedir
}

function setterPluginSetup (setter, fns) {
let methods = is.array(fns) ? fns : [ fns ]
methods = methods.map(m => {
Expand All @@ -11,5 +18,6 @@ function setterPluginSetup (setter, fns) {
}

module.exports = {
setterPluginSetup
getHomedir,
setterPluginSetup,
}
12 changes: 3 additions & 9 deletions test/unit/src/config/project/index-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
let { join } = require('path')
let { homedir } = require('os')
let test = require('tape')
let mockTmp = require('mock-tmp')
let cwd = process.cwd()
let testLibPath = join(cwd, 'test', 'lib')
let { getHomedir } = require(testLibPath)
let inventoryDefaultsPath = join(process.cwd(), 'src', 'defaults')
let inventoryDefaults = require(inventoryDefaultsPath)
let defaultFunctionConfigPath = join(process.cwd(), 'src', 'defaults', 'function-config')
Expand All @@ -11,14 +12,7 @@ let sut = join(cwd, 'src', 'config', 'project')
let getProjectConfig = require(sut)

let localPrefsFile = 'prefs.arc'
let _homedir = homedir()
// TODO ↓ remove me! ↓
console.log(`_homedir:`, _homedir)
// TODO ↓ remove me! ↓
console.log(`cwd:`, cwd)
if (process.platform === 'win32') _homedir = _homedir.replace(/^[A-Z]:\\/, '')
// TODO ↓ remove me! ↓
console.log(`_homedir:`, _homedir)
let _homedir = getHomedir()
let globalPrefsFile = join(_homedir, 'prefs.arc')
let _testing = true

Expand Down
6 changes: 4 additions & 2 deletions test/unit/src/config/project/prefs/index-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
let { join } = require('path')
let { homedir } = require('os')
let test = require('tape')
let mockTmp = require('mock-tmp')
let cwd = process.cwd()
let testLibPath = join(cwd, 'test', 'lib')
let { getHomedir } = require(testLibPath)
let inventoryDefaultsPath = join(cwd, 'src', 'defaults')
let inventoryDefaults = require(inventoryDefaultsPath)
let sut = join(cwd, 'src', 'config', 'project', 'prefs')
let getPrefs = require(sut)

let path = join(homedir(), '.prefs.arc')
let _homedir = getHomedir()
let path = join(_homedir, '.prefs.arc')
let reset = () => mockTmp.restore()
function clean (preferences) {
// Delete the meta stuff so the actual preferences match during an equality check
Expand Down

0 comments on commit 75f1053

Please sign in to comment.