writeWordpressDdevSettingsFile unconditionally creates the file that contains ddev-specific settings.
(filePath string)
| 176 | |
| 177 | // writeWordpressDdevSettingsFile unconditionally creates the file that contains ddev-specific settings. |
| 178 | func writeWordpressDdevSettingsFile(filePath string) error { |
| 179 | if fileutil.FileExists(filePath) { |
| 180 | // Check if the file is managed by ddev. |
| 181 | signatureFound, err := fileutil.FgrepStringInFile(filePath, nodeps.DdevFileSignature) |
| 182 | if err != nil { |
| 183 | return err |
| 184 | } |
| 185 | |
| 186 | // If the signature wasn't found, warn the user and return. |
| 187 | if !signatureFound { |
| 188 | util.Warning("%s already exists and is managed by the user.", filepath.Base(filePath)) |
| 189 | return nil |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | content, err := bundledAssets.ReadFile("wordpress/wp-config-ddev.php") |
| 194 | if err != nil { |
| 195 | return err |
| 196 | } |
| 197 | |
| 198 | // Ensure target directory exists and is writable |
| 199 | dir := filepath.Dir(filePath) |
| 200 | if err = util.Chmod(dir, 0755); os.IsNotExist(err) { |
| 201 | if err = os.MkdirAll(dir, 0755); err != nil { |
| 202 | return err |
| 203 | } |
| 204 | } else if err != nil { |
| 205 | return err |
| 206 | } |
| 207 | |
| 208 | return os.WriteFile(filePath, content, 0644) |
| 209 | } |
| 210 | |
| 211 | // setWordpressSiteSettingsPaths sets the expected settings files paths for |
| 212 | // a WordPress site. |
no test coverage detected