Skip to content

Commit c3f6f8c

Browse files
committed
feat: Added additional tests to confirm resolver and fixed uninstall script
1 parent e3ce624 commit c3f6f8c

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

scripts/uninstall.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@ if [[ $(/usr/bin/id -u) -ne 0 ]]; then
66
exit
77
fi
88

9-
BIN_LOCATION=$(which codify)
9+
BIN_LOCATION=$(which codify) || { echo "Codify not found! Nothing to uninstall"; exit 0; }
1010
LIB_LOCATION=$(dirname "$(readlink -f $BIN_LOCATION)")
1111

12-
sudo bash "$LIB_LOCATION/uninstall"
13-
rm -rf $HOME/.codify
12+
echo "Removing $BIN_LOCATION"
13+
rm -f $BIN_LOCATION
14+
15+
echo "Removing $(realpath $LIB_LOCATION/..)"
16+
rm -rf "$(realpath "$LIB_LOCATION"/..)"
17+
18+
echo "Removing \$HOME/.codify"
19+
rm -rf "$HOME/.codify"
20+
21+
echo "Removing \$HOME/.local/share/codify/"
22+
rm -rf $HOME/.local/share/codify/
23+
24+
echo "Done uninstalling codify. We're sorry to see you go."

test/integration/resolver.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ describe('Plugin resolver integration test', () => {
3535
expect(pluginFolder[0]).to.eq('index.js')
3636
})
3737

38+
it ('works after .DS_store exists in the plugins folder', async() => {
39+
const pluginsFolder = path.resolve(os.homedir(), '.codify', 'plugins');
40+
fs.mkdirSync(pluginsFolder, { recursive: true });
41+
fs.writeFileSync(path.resolve(pluginsFolder, '.DS_store'), 'ghjh');
42+
43+
await PluginResolver.resolveAll({ 'default': 'latest' })
44+
45+
expect(fs.readdirSync(pluginsFolder)).toMatchObject([
46+
'.DS_store',
47+
'default'
48+
])
49+
50+
const versions = fs.readdirSync(path.resolve(pluginsFolder, 'default'));
51+
const defaultPluginFolder = path.resolve(pluginsFolder, 'default');
52+
expect(versions.length).to.eq(1);
53+
54+
fs.rmSync(path.resolve(defaultPluginFolder, versions[0]), { recursive: true, force: true });
55+
fs.writeFileSync(path.resolve(defaultPluginFolder, '.DS_store'), 'ghjh');
56+
57+
await PluginResolver.resolveAll({ 'default': 'latest' })
58+
expect(fs.readdirSync(defaultPluginFolder)).toMatchObject([
59+
'.DS_store',
60+
versions[0],
61+
])
62+
})
63+
3864
afterEach(() => {
3965
vi.resetAllMocks();
4066
})

0 commit comments

Comments
 (0)