@sveltejs/adapter-netlify
Advanced tools
Comparing version 2.0.1 to 2.0.2
45
index.js
@@ -1,2 +0,9 @@ | ||
import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'fs'; | ||
import { | ||
appendFileSync, | ||
existsSync, | ||
readFileSync, | ||
writeFileSync, | ||
unlinkSync, | ||
createReadStream | ||
} from 'fs'; | ||
import { dirname, join, resolve, posix } from 'path'; | ||
@@ -6,2 +13,3 @@ import { fileURLToPath } from 'url'; | ||
import toml from '@iarna/toml'; | ||
import { createInterface } from 'readline'; | ||
@@ -55,6 +63,39 @@ /** | ||
const redirects_file_path = join(publish, '_redirects'); | ||
// If redirects file exists - empty any netlify generated files in functions-internal | ||
// Without removing other files that may have been auto generated by integrations | ||
if (existsSync(redirects_file_path)) { | ||
// Read each line of the file | ||
const fileStream = createReadStream(redirects_file_path); | ||
const rl = createInterface({ | ||
input: fileStream, | ||
crlfDelay: Infinity | ||
}); | ||
// Create an array of lines | ||
const lines = []; | ||
for await (const line of rl) { | ||
lines.push(line); | ||
} | ||
const functions_internal = join('.netlify', 'functions-internal'); | ||
// Loop through redirects, and delete corresponding functions-internal files | ||
lines.forEach((line) => { | ||
if (line) { | ||
// example line /.netlify/functions/{function_name} 200 | ||
const path = line.split(' ')[1]; | ||
const function_name = path.split('/').pop(); | ||
const mjsFile = join(functions_internal, `${function_name}.mjs`); | ||
const jsonFile = join(functions_internal, `${function_name}.json`); | ||
if (existsSync(mjsFile)) unlinkSync(mjsFile); | ||
if (existsSync(jsonFile)) unlinkSync(jsonFile); | ||
} | ||
}); | ||
} | ||
// empty out existing build directories | ||
builder.rimraf(publish); | ||
builder.rimraf('.netlify/edge-functions'); | ||
builder.rimraf('.netlify/functions-internal'); | ||
builder.rimraf('.netlify/server'); | ||
@@ -61,0 +102,0 @@ builder.rimraf('.netlify/package.json'); |
{ | ||
"name": "@sveltejs/adapter-netlify", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"repository": { | ||
@@ -41,3 +41,3 @@ "type": "git", | ||
"uvu": "^0.5.6", | ||
"@sveltejs/kit": "^1.5.0" | ||
"@sveltejs/kit": "^1.5.1" | ||
}, | ||
@@ -44,0 +44,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
798105
18740