prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  `mkdocs new` will overwrite an existing index.md file without warning.
  If you run the command: `mkdocs new /path/to/dir` and `/path/to/dir/docs/index.md` already exists it will be replaced with out placeholder.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mkdocs/new.py`
  Content:
  ```
  1 # coding: utf-8
  2 from __future__ import print_function
  3 import os
  4 
  5 config_text = 'site_name: My Docs\n'
  6 index_text = """# Welcome to MkDocs
  7 
  8 For full documentation visit [mkdocs.org](http://mkdocs.org).
  9 
  10 ## Commands
  11 
  12 * `mkdocs new [dir-name]` - Create a new project.
  13 * `mkdocs serve` - Start the live-reloading docs server.
  14 * `mkdocs build` - Build the documentation site.
  15 * `mkdocs help` - Print this help message.
  16 
  17 ## Project layout
  18 
  19     mkdocs.yml    # The configuration file.
  20     docs/
  21         index.md  # The documentation homepage.
  22         ...       # Other markdown pages, images and other files.
  23 """
  24 
  25 
  26 def new(args, options):
  27     if len(args) != 1:
  28         print("Usage 'mkdocs new [directory-name]'")
  29         return
  30 
  31     output_dir = args[0]
  32 
  33     docs_dir = os.path.join(output_dir, 'docs')
  34     config_path = os.path.join(output_dir, 'mkdocs.yml')
  35     index_path = os.path.join(docs_dir, 'index.md')
  36 
  37     if os.path.exists(config_path):
  38         print('Project already exists.')
  39         return
  40 
  41     if not os.path.exists(output_dir):
  42         print('Creating project directory: %s' % output_dir)
  43         os.mkdir(output_dir)
  44 
  45     print('Writing config file: %s' % config_path)
  46     open(config_path, 'w').write(config_text)
  47 
  48     print('Writing initial docs: %s' % index_path)
  49     if not os.path.exists(docs_dir):
  50         os.mkdir(docs_dir)
  51     open(index_path, 'w').write(index_text)
  52
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/mkdocs/new.py b/mkdocs/new.py
  --- a/mkdocs/new.py
  +++ b/mkdocs/new.py
  @@ -45,6 +45,9 @@
       print('Writing config file: %s' % config_path)
       open(config_path, 'w').write(config_text)
   
  +    if os.path.exists(index_path):
  +        return
  +
       print('Writing initial docs: %s' % index_path)
       if not os.path.exists(docs_dir):
           os.mkdir(docs_dir)
  
verification_info: {"golden_diff": "diff --git a/mkdocs/new.py b/mkdocs/new.py\n--- a/mkdocs/new.py\n+++ b/mkdocs/new.py\n@@ -45,6 +45,9 @@\n     print('Writing config file: %s' % config_path)\n     open(config_path, 'w').write(config_text)\n \n+    if os.path.exists(index_path):\n+        return\n+\n     print('Writing initial docs: %s' % index_path)\n     if not os.path.exists(docs_dir):\n         os.mkdir(docs_dir)\n", "issue": "`mkdocs new` will overwrite an existing index.md file without warning.\nIf you run the command: `mkdocs new /path/to/dir` and `/path/to/dir/docs/index.md` already exists it will be replaced with out placeholder.\n\n", "before_files": [{"content": "# coding: utf-8\nfrom __future__ import print_function\nimport os\n\nconfig_text = 'site_name: My Docs\\n'\nindex_text = \"\"\"# Welcome to MkDocs\n\nFor full documentation visit [mkdocs.org](http://mkdocs.org).\n\n## Commands\n\n* `mkdocs new [dir-name]` - Create a new project.\n* `mkdocs serve` - Start the live-reloading docs server.\n* `mkdocs build` - Build the documentation site.\n* `mkdocs help` - Print this help message.\n\n## Project layout\n\n    mkdocs.yml    # The configuration file.\n    docs/\n        index.md  # The documentation homepage.\n        ...       # Other markdown pages, images and other files.\n\"\"\"\n\n\ndef new(args, options):\n    if len(args) != 1:\n        print(\"Usage 'mkdocs new [directory-name]'\")\n        return\n\n    output_dir = args[0]\n\n    docs_dir = os.path.join(output_dir, 'docs')\n    config_path = os.path.join(output_dir, 'mkdocs.yml')\n    index_path = os.path.join(docs_dir, 'index.md')\n\n    if os.path.exists(config_path):\n        print('Project already exists.')\n        return\n\n    if not os.path.exists(output_dir):\n        print('Creating project directory: %s' % output_dir)\n        os.mkdir(output_dir)\n\n    print('Writing config file: %s' % config_path)\n    open(config_path, 'w').write(config_text)\n\n    print('Writing initial docs: %s' % index_path)\n    if not os.path.exists(docs_dir):\n        os.mkdir(docs_dir)\n    open(index_path, 'w').write(index_text)\n", "path": "mkdocs/new.py"}], "after_files": [{"content": "# coding: utf-8\nfrom __future__ import print_function\nimport os\n\nconfig_text = 'site_name: My Docs\\n'\nindex_text = \"\"\"# Welcome to MkDocs\n\nFor full documentation visit [mkdocs.org](http://mkdocs.org).\n\n## Commands\n\n* `mkdocs new [dir-name]` - Create a new project.\n* `mkdocs serve` - Start the live-reloading docs server.\n* `mkdocs build` - Build the documentation site.\n* `mkdocs help` - Print this help message.\n\n## Project layout\n\n    mkdocs.yml    # The configuration file.\n    docs/\n        index.md  # The documentation homepage.\n        ...       # Other markdown pages, images and other files.\n\"\"\"\n\n\ndef new(args, options):\n    if len(args) != 1:\n        print(\"Usage 'mkdocs new [directory-name]'\")\n        return\n\n    output_dir = args[0]\n\n    docs_dir = os.path.join(output_dir, 'docs')\n    config_path = os.path.join(output_dir, 'mkdocs.yml')\n    index_path = os.path.join(docs_dir, 'index.md')\n\n    if os.path.exists(config_path):\n        print('Project already exists.')\n        return\n\n    if not os.path.exists(output_dir):\n        print('Creating project directory: %s' % output_dir)\n        os.mkdir(output_dir)\n\n    print('Writing config file: %s' % config_path)\n    open(config_path, 'w').write(config_text)\n\n    if os.path.exists(index_path):\n        return\n\n    print('Writing initial docs: %s' % index_path)\n    if not os.path.exists(docs_dir):\n        os.mkdir(docs_dir)\n    open(index_path, 'w').write(index_text)\n", "path": "mkdocs/new.py"}]}