-- ROBLOX deviation: we change from backtick to our literal string delimiter [=[ and ]=]

local function printBacktickString(str: string): string
	return "[=[\n" .. str .. "]=]"
end

local function ensureDirectoryExists(filePath: string)
	-- ROBLOX deviation: gets path of parent directory, GetScriptFilePath can only be called on ModuleScripts
	local pathComponents = filePath:split("/")
	pathComponents = table.pack(table.unpack(pathComponents, 1, #pathComponents - 1))
	local path = table.concat(pathComponents, "/")
	local ok, err = pcall(function()
		if not FileSystemService:Exists(path) then
			FileSystemService:CreateDirectories(path)
		end
	end)

	if not ok and err:find("Error%(13%): Access Denied%. Path is outside of sandbox%.") then
		error(
			"Provided path is invalid: you likely need to provide a different argument to --fs.readwrite.\n"
				.. "You may need to pass in `--fs.readwrite=$PWD`"
		)
	end
end

function normalizeNewLines(string_: string)
	string_ = string.gsub(string_, "\r\n", "\n")
	local result = string.gsub(string_, "\r", "\n")
	return result
end
