Make options.base an array before assigning directory

If options.base is not an array, `options.base[options.base.length - 1]` is not what you want for `directory`.